Sign In
Open your user center to view only your own balance, access, and usage.
QUICK START
Open your user center to view only your own balance, access, and usage.
Name the key, set its limits, and use every enabled model.
Set the API Base URL in your client and keep its native protocol.
From sign-up to your first request in about five minutes.
curl https://api.luckyapi.online/v1/responses \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.6-sol",
"input": "Introduce yourself in one sentence"
}'
A JSON response means the whole chain works. Model names follow the live list on the pricing page.
Every request goes to the same base URL, authenticated with your API key as a Bearer token.
| Protocol / capability | Endpoint |
|---|---|
| OpenAI Responses protocol | POST /v1/responses |
| OpenAI Chat Completions | POST /v1/chat/completions |
| Anthropic Messages protocol | POST /v1/messages |
| Model list | GET /v1/models |
| Image generation & edits | POST /v1/images/generations · /v1/images/edits |
| Video generation (async) | POST /v1/videos/generations |
Request bodies match each official protocol; complete runnable examples for the media APIs live in the chapters on the left.
Manage providers through a GUI — the simplest way to connect Codex and Claude Code.
Codex CLI and Codex Desktop share the same user-level config when they run under the same system user and CODEX_HOME. After saving, restart Codex Desktop or open a new Codex CLI session.
model = "gpt-5.6-sol"
model_provider = "luckyapi"
[model_providers.luckyapi]
name = "LuckyAPI"
base_url = "https://api.luckyapi.online/v1"
wire_api = "responses"
requires_openai_auth = false
experimental_bearer_token = "YOUR_API_KEY"
Set the native endpoint and auth token in the Claude Code user settings — configure once, use continuously.
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.luckyapi.online",
"ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY"
}
}
Restart the client after saving the config.
Supports both text-to-image and reference-image edits. Image requests are usually slower than text — give your client a longer timeout.
curl -sS --max-time 600 \
https://api.luckyapi.online/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "A red apple on a wooden table, square 1:1 composition",
"n": 1,
"response_format": "b64_json"
}' \
-o image-response.json
curl -sS --max-time 600 \
https://api.luckyapi.online/v1/images/edits \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "model=gpt-image-2" \
-F "prompt=Combine the references into one cyberpunk scene, keep the subjects and use a square 1:1 composition" \
-F "image[]=@./reference-1.png" \
-F "image[]=@./reference-2.png" \
-F "image[]=@./reference-3.png" \
-F "n=1" \
-F "response_format=b64_json" \
-o image-edit-response.json
Use the same LuckyAPI key for Grok text-to-image, or edit up to 3 local reference images.
curl -sS --fail-with-body --max-time 600 \
https://api.luckyapi.online/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-imagine-image-quality",
"prompt": "A cinematic spacecraft leaving a Martian canyon",
"aspect_ratio": "16:9",
"resolution": "2k",
"n": 1,
"response_format": "url"
}' \
-o grok-image-response.json
RESPONSE=grok-image-response.json
jq . "$RESPONSE"
URL=$(jq -er '.data[0].url' "$RESPONSE") || exit 1
curl -fL "$URL" -o grok-image.png
curl -sS --fail-with-body --max-time 600 \
https://api.luckyapi.online/v1/images/edits \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "model=grok-imagine-image-quality" \
-F "prompt=Combine the subjects into one cinematic cyberpunk scene" \
-F "image=@./reference-1.png" \
-F "image=@./reference-2.png" \
-F "image=@./reference-3.png" \
-o grok-image-edit-response.json
Video generation is asynchronous: submit a job, poll its status when needed, then let the protected content endpoint wait and download the MP4 for you.
API_KEY="YOUR_API_KEY"
BASE="https://api.luckyapi.online"
ID=$(curl -fsS "$BASE/v1/videos/generations" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-imagine-video-1.5",
"prompt": "A cinematic spacecraft leaving a Martian canyon",
"duration": 10,
"aspect_ratio": "16:9",
"resolution": "720p"
}' \
| jq -er '.request_id') || exit 1
printf 'Request ID: %s\n' "$ID"
curl -fsS "$BASE/v1/videos/$ID" \
-H "Authorization: Bearer $API_KEY" | jq .
curl -fSL --retry 120 --retry-delay 5 --retry-all-errors \
"$BASE/v1/videos/$ID/content" \
-H "Authorization: Bearer $API_KEY" \
-o grok-video.mp4
pending means still generating; done means the video is ready; failed or expired means the job did not finish — check the upstream error in the full status response. The download command retries every 5 seconds for up to about 10 minutes and never saves an HTTP error body as an MP4.
base64 < ./reference.png | tr -d '\n' | \
jq -Rs '{
model: "grok-imagine-video-1.5",
prompt: "Animate this still image with a slow cinematic camera move",
image: {url: ("data:image/png;base64," + .)},
duration: 10,
resolution: "720p"
}' > grok-video-request.json
curl -sS --fail-with-body \
https://api.luckyapi.online/v1/videos/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
--data-binary @grok-video-request.json | jq .
image accepts one public HTTPS URL, base64 data URI or file_id, and uses it as the first frame. Once you have the request_id, reuse the status and content endpoints above.
curl -sS --fail-with-body \
https://api.luckyapi.online/v1/videos/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-imagine-video-1.5",
"prompt": "Use the person from <IMAGE_0> and the clothing from <IMAGE_1>",
"reference_images": [
{"url": "https://example.com/person.png"},
{"url": "https://example.com/clothing.png"}
],
"duration": 10,
"aspect_ratio": "16:9",
"resolution": "720p"
}' | jq .
Gemini Omni is an async video API supporting text-to-video, one local first-frame image, or 1–5 local reference images; each request returns one MP4.
API_KEY="YOUR_API_KEY"
BASE="https://api.luckyapi.online"
ID=$(curl -fsS "$BASE/v1/videos/generations" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-omni-flash",
"prompt": "A cinematic sunrise over the ocean with a slow camera push",
"duration": 8,
"aspect_ratio": "16:9",
"resolution": "720p"
}' \
| jq -er '.request_id') || exit 1
printf 'Request ID: %s\n' "$ID"
curl -fsS "$BASE/v1/videos/$ID" \
-H "Authorization: Bearer $API_KEY" | jq .
curl -fSL --retry 120 --retry-delay 5 --retry-all-errors \
"$BASE/v1/videos/$ID/content" \
-H "Authorization: Bearer $API_KEY" \
-o gemini-omni.mp4
pending means still generating; done means the MP4 is ready; failed means this generation did not finish — check the upstream error in the full status response. The download command retries every 5 seconds for up to about 10 minutes.
curl -sS --fail-with-body \
https://api.luckyapi.online/v1/videos/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "model=gemini-omni-flash" \
-F "prompt=Animate this first frame with a slow cinematic camera move" \
-F "duration=8" \
-F "aspect_ratio=16:9" \
-F "resolution=720p" \
-F "image=@./first-frame.jpg;type=image/jpeg" | jq .
image accepts exactly one local PNG or JPEG and locks it as the first frame. Once you have the request_id, reuse the status and content endpoints above.
curl -sS --fail-with-body \
https://api.luckyapi.online/v1/videos/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "model=gemini-omni-flash" \
-F "prompt=Use the person and wardrobe from the reference images" \
-F "duration=8" \
-F "aspect_ratio=9:16" \
-F "resolution=720p" \
-F "reference_images=@./person.png;type=image/png" \
-F "reference_images=@./wardrobe.jpg;type=image/jpeg" | jq .
gpt-5.6-lunaOpenAI
gpt-5.6-terraOpenAI
gpt-5.6-solOpenAI
gpt-image-2OpenAI gpt-5.3-codex-spark | OpenAI | $0.175 | $0.0175 | $1.4 | -90% | |
gpt-5.4 | OpenAI | $0.25 | $0.025 | $1.5 | -90% | |
gpt-5.4-mini | OpenAI | $0.075 | $0.0075 | $0.45 | -90% | |
gpt-5.5 | OpenAI | $0.5 | $0.05 | $3 | -90% | |
gpt-5.6-luna | OpenAI | $0.02 | $0.002 | $0.025 | $0.12 | -90% |
gpt-5.6-sol | OpenAI | $0.5 | $0.05 | $0.625 | $3 | -90% |
gpt-5.6-terra | OpenAI | $0.2 | $0.02 | $0.25 | $1.2 | -90% |
Revocation and deletion take effect immediately. Historical usage and billing remain available.
| Name | Status | Quota | Expiration | Last Used | Actions |
|---|