Skip to content

Conversation

@konard
Copy link
Contributor

@konard konard commented Dec 9, 2025

Summary

This PR adds comprehensive examples for accessing the unofficial Midjourney API via Legnext in both JavaScript and Python, along with GitHub Actions workflows to run them manually.

Changes Made

JavaScript Example

  • ✅ Created examples/javascript/midjourney-example.js with full implementation
    • Generates images using Midjourney via Legnext API
    • Polls for job completion with status tracking
    • Retrieves and displays generated image URLs
  • ✅ Updated package.json with node-fetch dependency and midjourney script
  • ✅ Updated .env.example with Legnext API credentials
  • ✅ Updated README with comprehensive Midjourney example instructions

Python Example

  • ✅ Created examples/python/midjourney_example.py with full implementation
    • Generates images using Midjourney via Legnext API
    • Polls for job completion with status tracking
    • Retrieves and displays generated image URLs
  • ✅ Updated requirements.txt with requests dependency
  • ✅ Updated .env.example with Legnext API credentials
  • ✅ Updated README with comprehensive Midjourney example instructions

GitHub Actions Workflows

  • ✅ Created .github/workflows/run-javascript-midjourney.yml
    • Manually triggerable via workflow_dispatch
    • Accepts custom prompts as input
    • Uses repository secrets for API keys
  • ✅ Created .github/workflows/run-python-midjourney.yml
    • Manually triggerable via workflow_dispatch
    • Accepts custom prompts as input
    • Uses repository secrets for API keys

API Documentation Reference

The implementation is based on the official Legnext API documentation:

  • Base URL: https://api.legnext.ai/api
  • Image generation endpoint: /v1/diffusion (POST)
  • Job status endpoint: /v1/job/{job_id} (GET)
  • Authentication: x-api-key header

How to Use

JavaScript Example

cd examples/javascript
npm install
cp .env.example .env
# Edit .env with your Legnext API key
npm run midjourney

Python Example

cd examples/python
pip install -r requirements.txt
cp .env.example .env
# Edit .env with your Legnext API key
python midjourney_example.py

GitHub Actions

Navigate to the Actions tab and run either:

  • "Run JavaScript Midjourney Example" workflow
  • "Run Python Midjourney Example" workflow

Note: You need to add LEGNEXT_API_KEY to the repository secrets first.

Testing

  • ✅ JavaScript syntax validated
  • ✅ Python syntax validated
  • ✅ Both examples follow the existing code style
  • ✅ READMEs updated with clear instructions
  • ✅ Environment variable configuration documented

Closes

Fixes #1


🤖 Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #1
@konard konard self-assigned this Dec 9, 2025
konard and others added 3 commits December 9, 2025 06:29
- Create midjourney-example.js with complete implementation
- Add node-fetch dependency to package.json
- Update .env.example with Legnext API credentials
- Update README with Midjourney example instructions

The example demonstrates:
- Creating image generation jobs with text prompts
- Polling for job completion with status tracking
- Retrieving generated image URLs and available actions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Create midjourney_example.py with complete implementation
- Add requests dependency to requirements.txt
- Update .env.example with Legnext API credentials
- Update README with Midjourney example instructions

The example demonstrates:
- Creating image generation jobs with text prompts
- Polling for job completion with status tracking
- Retrieving generated image URLs and available actions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Create workflow for JavaScript Midjourney example
- Create workflow for Python Midjourney example
- Both workflows are manually triggerable via workflow_dispatch
- Support custom prompts as workflow inputs
- Use repository secrets for API keys
- Upload execution logs as artifacts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard changed the title [WIP] Create an example in JavaScript and Python on how to access unofficial Midjourney api via Legnext Create examples in JavaScript and Python for Midjourney API via Legnext Dec 9, 2025
@konard konard marked this pull request as ready for review December 9, 2025 05:32
@konard
Copy link
Contributor Author

konard commented Dec 9, 2025

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $1.312495 USD
  • Calculated by Anthropic: $1.169931 USD
  • Difference: $-0.142564 (-10.86%)
    📎 Log file uploaded as GitHub Gist (299KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Contributor Author

konard commented Dec 9, 2025

🔄 Auto-restart 1/3

Detected uncommitted changes from previous run. Starting new session to review and commit them.

Uncommitted files:

?? examples/python/__pycache__/

Auto-restart will stop after changes are committed or after 2 more iterations. Please wait until working session will end and give your feedback.

Added __pycache__/ and Python bytecode files (*.pyc, *.pyo, *.pyd) to prevent them from being tracked in the repository.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@konard
Copy link
Contributor Author

konard commented Dec 9, 2025

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $1.153445 USD
  • Calculated by Anthropic: $0.603073 USD
  • Difference: $-0.550373 (-47.72%)
    📎 Log file uploaded as GitHub Gist (572KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create an example in JavaScript and Python on how to access unofficial Midjourney api via Legnext

2 participants