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.
从注册到发出第一个请求,大约五分钟。
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"
}'
返回 JSON 即表示链路全通。模型名以控制台模型页的实际列表为准。
下一步:接入一个编程工具,或直接调用媒体 API。
所有请求发往同一个 Base URL,用 API Key 作为 Bearer 令牌认证。
https://api.luckyapi.online
Authorization: Bearer YOUR_API_KEY
| 协议 / 能力 | 端点 |
|---|---|
| OpenAI Responses 协议 | POST /v1/responses |
| OpenAI Chat Completions | POST /v1/chat/completions |
| Anthropic Messages 协议 | POST /v1/messages |
| 模型列表 | GET /v1/models |
| 图像生成与编辑 | POST /v1/images/generations · /v1/images/edits |
| 视频生成(异步) | POST /v1/videos/generations |
各协议请求体与官方格式一致;媒体 API 的完整可运行示例见左侧对应章节。
通过图形界面管理 Provider,是 Codex 和 Claude Code 最简单的接入方式。
Codex CLI 与 Codex Desktop 在系统用户和 CODEX_HOME 相同时,共用同一份用户级配置。保存后重启 Codex Desktop,或新开一个 Codex CLI 会话。
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"
在 Claude Code 用户配置中设置原生接口地址和认证 Token,一次配置即可持续使用。
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.luckyapi.online",
"ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY"
}
}
保存配置后,请重启客户端。
同时支持文生图和参考图编辑。图片请求通常比文本请求更慢,请为客户端设置更长的超时时间。
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
使用同一个 LuckyAPI Key 完成 Grok 文生图,或编辑最多 3 张本地参考图。
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
视频生成是异步任务:先提交任务,需要时查询状态,再通过受保护的内容端点自动等待并下载 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": "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 表示仍在生成;done 表示视频已经完成;failed 或 expired 表示本次任务未完成,应查看完整状态响应中的上游错误。下载命令每 5 秒重试一次,最长约 10 分钟,并且不会把 HTTP 错误正文保存成 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 接受 1 个公开 HTTPS 地址、base64 Data URI 或 file_id,并将其作为视频首帧。拿到 request_id 后,继续复用上方的状态查询与内容下载端点。
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 是异步视频接口,支持文生视频、1 张本地首帧图或 1–5 张本地参考图;每次请求返回 1 个 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 表示仍在生成;done 表示 MP4 已经完成;failed 表示本次生成未完成,应查看完整状态响应中的上游错误。下载命令每 5 秒重试一次,最长约 10 分钟。
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 只接受 1 张本地 PNG 或 JPEG,并将其固定为视频首帧。拿到 request_id 后,继续复用上方的状态查询与内容下载端点。
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 .
No matching models.
PARTNERSHIPS
Token sponsorship for quality projects, helping them reach more users.
A 30% token revenue share for quality software and agents: integrate our tokens into your product and earn on every user's usage.
Reach us through the channel where you received LuckyAPI access.
Effective: July 24, 2026
This policy explains how LuckyAPI handles information while providing accounts, API access, usage, and billing features.
We process account email and username, session and security metadata, and usage, billing, and payment-status records.
Account identity and credentials are processed to authenticate you, protect access, and recover your account.
Information is used to create and protect accounts, issue local sessions, provide API service, record usage, settle charges, prevent abuse, and meet necessary security and legal obligations.
We do not sell personal information. Information is processed only as needed for hosting, payment, security, or legal compliance, and retained only for operational, security, accounting, and legal needs.
To request access, correction, or deletion of account data, use the contact channel through which your LuckyAPI access was provided.
Effective: July 24, 2026
By using LuckyAPI, you agree to these service terms.
Provide accurate account information and protect sessions, passwords, and API keys. Accounts and keys may not be sold, leased, or used for unauthorized access.
Do not use the service unlawfully, infringe rights, bypass access controls, attack systems, distribute malware, or interfere with other users or upstream services.
Billing is based on LuckyAPI records of requests, tokens, models, rates, and applicable multipliers. Top-ups, refunds, and payment status follow verified payment results and the rules shown in the product.
Upstream models and networks can change or fail. LuckyAPI may limit or suspend access for security, compliance, maintenance, or abuse risk, while making reasonable efforts to keep records accurate and service available.
Material changes update the effective date on this page. Continued use after a change means acceptance of the updated terms.
Revocation and deletion take effect immediately. Historical usage and billing remain available.
Copy and store it now. Do not share it. Revoke and replace it if exposure is suspected.
| Name | Status | Quota | Expiration | Last Used | Actions |
|---|
Submit a top-up request and wait for confirmation.
Review top-up requests and their current status.
| Order Number | Amount | Status | Created | Actions |
|---|
Review usage and cost changes for the selected time range.
Granularity is chosen automatically from the actual usage range.
Cost grouped by model for the same time range as the trend.
Daily token and cost totals.
| Date | Requests | Input | Cache Read | Cache Write | Output | Total Tokens | Cost |
|---|
Review every request, its usage and cost.
| Time | Provider | Model | Key | Request Type | Usage | Cost |
|---|