Text models swap the SDK base URL; video models submit tasks through /videos/v1/videos/generations.
STEP 03
Review results and usage
Text requests return in real time; video tasks are polled until complete, then results can be downloaded and roll up into usage records.
Last updated: 2026-09-04
03Endpoints
GET
/v1/models
Query current callable model IDs before integrating. ChatGPT model IDs follow this list.
POST
/v1/chat/completions
OpenAI-compatible endpoint. After swapping the base URL, the OpenAI SDK, Cursor, Codex CLI, opencode, and LangChain can all call through here.
POST
/v1/messages
Anthropic Messages-native endpoint. Claude Code and the Anthropic SDK can switch directly to the Try AI API base URL.
POST
/videos/v1/videos/generations
Video model async task endpoint. Submit a prompt, duration, resolution, and aspect ratio to receive a job_id and poll_url.
GET
/videos/v1/videos/jobs/{job_id}
Prefer the poll_url returned by submission; it provides task status, completed output, failure details, and the video download URL.
POST
/videos/api/v3/contents/generations/tasks
Volcano Ark native-format entry for video models. model accepts the official IDs (doubao-seedance-2-0-260128 / doubao-seedance-2-0-fast-260128 / doubao-seedance-2-5-260628); unsupported top-level parameters return an explicit error and are never silently dropped.
GET
/videos/api/v3/contents/generations/tasks/{id}
Ark native-format task query entry; returns Ark status values (queued / running / succeeded / failed / cancelled / expired). On success content.video_url is the generation engine's official link (typically valid ~24 hours), identical to video_url on the standard endpoint. When a platform copy exists, content.platform_video_url and content.platform_expires_at are also included (kept for 7 days on our side; these two fields are gateway additions and are absent from the Ark native format).
Developers already using the Volcano Ark native request format can use the Ark-compatible endpoint above directly; see the specific differences from Ark native in the Video Model API Integration Guide's "Ark-compatible endpoint: differences from Ark native".
Last updated: 2026-09-04
04Advanced scenario examples
Advanced text capabilities and video model async task examples — each scenario shown in cURL / Python / JavaScript.
curl -N https://tryaiapi.com/v1/chat/completions \
-H"Authorization: Bearer $TRYAIAPI_KEY" \
-H"Content-Type: application/json" \
-d'{
"model": "claude-sonnet-5",
"messages": [{"role": "user", "content": "Write a short poem about clouds"}],
"stream": true
}'
Python · streaming response
from openai import OpenAI
client = OpenAI(base_url="https://tryaiapi.com/v1", api_key="$TRYAIAPI_KEY")
stream = client.chat.completions.create(
model="claude-sonnet-5",
messages=[{"role": "user", "content": "Write a short poem about clouds"}],
stream=True,
)
for chunk in stream:
print(chunk.choices[0].delta.content or"", end="")
JavaScript · streaming response
import OpenAI from"openai";
const client = new OpenAI({
baseURL: "https://tryaiapi.com/v1",
apiKey: process.env.TRYAIAPI_KEY,
});
const stream = await client.chat.completions.create({
model: "claude-sonnet-5",
messages: [{ role: "user", content: "Write a short poem about clouds" }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0].delta.content ?? "");
}
cURL · video model async task
# 1. Submit job and capture the returned poll_url
POLL_URL=$(curl -sS https://tryaiapi.com/videos/v1/videos/generations \
-H"Authorization: Bearer $TRYAIAPI_KEY" \
-H"Content-Type: application/json" \
-d'{
"model": "doubao-seedance-2.0",
"prompt": "A cinematic product shot on a clean studio desk",
"duration": 5,
"resolution": "480p",
"aspect_ratio": "16:9"
}' | jq -r '.poll_url')
# 2. Poll the exact URL returned by the APIcurl"$POLL_URL" \
-H"Authorization: Bearer $TRYAIAPI_KEY"
cURL · Volcano Ark native format
# 1. Submit the task (Ark native shape: content array + ratio field)
TASK_ID=$(curl -sS https://tryaiapi.com/videos/api/v3/contents/generations/tasks \
-H"Authorization: Bearer $TRYAIAPI_KEY" \
-H"Content-Type: application/json" \
-d'{
"model": "doubao-seedance-2-0-260128",
"content": [
{ "type": "text", "text": "A cinematic product shot on a clean studio desk" }
],
"duration": 5,
"resolution": "480p",
"ratio": "16:9"
}' | jq -r '.id')
# 2. Query the task (content.video_url = official link, ~24h;# content.platform_video_url is our 7-day copy when present)curl"https://tryaiapi.com/videos/api/v3/contents/generations/tasks/$TASK_ID" \
-H"Authorization: Bearer $TRYAIAPI_KEY"
Python · video model async task
import os
import time
import requests
headers = {
"Authorization": f"Bearer {os.environ['TRYAIAPI_KEY']}",
"Content-Type": "application/json",
}
job = requests.post(
"https://tryaiapi.com/videos/v1/videos/generations",
headers=headers,
json={
"model": "doubao-seedance-2.0",
"prompt": "A cinematic product shot on a clean studio desk",
"duration": 5,
"resolution": "480p",
"aspect_ratio": "16:9",
},
)
job.raise_for_status()
poll_url = job.json()["poll_url"]
whileTrue:
result = requests.get(poll_url, headers=headers)
result.raise_for_status()
data = result.json()
if data["status"] in {"completed", "failed", "cancelled", "timeout"}:
print(data)
break
time.sleep(5)
JavaScript · video model async task
const headers = {
Authorization: `Bearer ${process.env.TRYAIAPI_KEY}`,
"Content-Type": "application/json",
};
const submit = await fetch("https://tryaiapi.com/videos/v1/videos/generations", {
method: "POST",
headers,
body: JSON.stringify({
model: "doubao-seedance-2.0",
prompt: "A cinematic product shot on a clean studio desk",
duration: 5,
resolution: "480p",
aspect_ratio: "16:9",
}),
});
const job = await submit.json();
while (true) {
const res = await fetch(job.poll_url, { headers });
const result = await res.json();
if (["completed", "failed", "cancelled", "timeout"].includes(result.status)) {
console.log(result);
break;
}
awaitnew Promise((resolve) => setTimeout(resolve, 5000));
}
Reference images. Each item is either a URL string (default role = first_frame, image-to-video) or an object {"url":"…","role":"first_frame|last_frame|reference_image"}
video_urls
array ≤3
Reference videos
audio_urls
array ≤3
Reference audio; cannot be used alone — must pair with a role:"reference_image" image or video_urls; first/last-frame images cannot be combined with audio
Billing: pre-held on submission, then reconciled against upstream usage.total_tokens; failed tasks are fully refunded.
Video link fields
Field
Description
video_url
Original video link from the generation engine, valid for about 24 hours (expires_at is the authoritative expiry).
platform_video_url
Platform storage link, kept for 7 days from job completion; once expired the file is deleted and cannot be recovered. null when the job has no platform copy — use video_url instead.
The platform uses official standard model IDs. Reasoning depth is controlled via API parameters — Anthropic uses the thinking object, OpenAI uses reasoning_effort.
Anthropic Claude · Enable Extended Thinking
curl https://tryaiapi.com/v1/messages \
-H"Authorization: Bearer $TRYAIAPI_KEY" \
-H"Content-Type: application/json" \
-H"anthropic-version: 2023-06-01" \
-d'{
"model": "claude-opus-4-7",
"max_tokens": 16000,
"thinking": {
"type": "enabled",
"budget_tokens": 10000
},
"messages": [{
"role": "user",
"content": "Explain the mechanism of quantum entanglement"
}]
}'# thinking.budget_tokens controls reasoning depth (1024 ~ 100000)# max_tokens must be > budget_tokens, to leave room for output# Supported: claude-opus-4-7, claude-opus-4-8, and other models with extended thinking
Python · Anthropic SDK
import anthropic
client = anthropic.Anthropic(
base_url="https://tryaiapi.com",
api_key="$TRYAIAPI_KEY",
)
resp = client.messages.create(
model="claude-opus-4-7",
max_tokens=16000,
thinking={
"type": "enabled",
"budget_tokens": 10000,
},
messages=[{"role": "user", "content": "Explain the mechanism of quantum entanglement"}],
)
for block in resp.content:
if block.type == "thinking":
print("[thinking]", block.thinking[:200], "...")
elif block.type == "text":
print("[answer]", block.text)
OpenAI · reasoning_effort parameter
curl https://tryaiapi.com/v1/chat/completions \
-H"Authorization: Bearer $TRYAIAPI_KEY" \
-H"Content-Type: application/json" \
-d'{
"model": "gpt-5.5",
"reasoning_effort": "high",
"messages": [{
"role": "user",
"content": "Explain the mechanism of quantum entanglement"
}]
}'# reasoning_effort: "low" | "medium" | "high" (default: medium)# Applies to gpt-5.5 and other reasoning models; check /v1/models for current IDs
Python · OpenAI SDK
from openai import OpenAI
client = OpenAI(base_url="https://tryaiapi.com/v1", api_key="$TRYAIAPI_KEY")
resp = client.chat.completions.create(
model="gpt-5.5",
reasoning_effort="high",
messages=[{"role": "user", "content": "Explain the mechanism of quantum entanglement"}],
)
print(resp.choices[0].message.content)
Last updated: 2026-09-04
05Client SDK configuration examples
Claude Code
All Claude models
⚠ ANTHROPIC_BASE_URL must stop at the hostname https://tryaiapi.com — do not add /v1 (unlike OpenAI; adding it would form /v1/v1/messages → 404)
# Set environment variables, then launch directlyexport ANTHROPIC_BASE_URL=https://tryaiapi.com
export ANTHROPIC_API_KEY=your-tryaiapi-key
claude
Cursor
Claude + ChatGPT + Grok
⚠ Base URL must include /v1 (Cursor appends /chat/completions directly to this OpenAI-protocol endpoint — unlike Claude Code's ANTHROPIC_BASE_URL, which does not take /v1)
# Settings → Models → Override OpenAI Base URL
Base URL: https://tryaiapi.com/v1
API Key: your-tryaiapi-key# Claude and Grok: use model IDs directly (e.g. claude-sonnet-5 / grok-4.6); ChatGPT model IDs: check /v1/models first
# Swap providers by changing the model namefrom openai import OpenAI
client = OpenAI(
base_url="https://tryaiapi.com/v1",
api_key="your-tryaiapi-key",
)
# Claude
resp = client.chat.completions.create(
model="claude-sonnet-5",
messages=[{"role": "user", "content": "Hello"}],
)
# ChatGPT — same client; check /v1/models for the current model ID
resp = client.chat.completions.create(
model="gpt-5.5",
messages=[{"role": "user", "content": "Hello"}],
)
# Grok — same client, just swap the model
resp = client.chat.completions.create(
model="grok-4.6",
messages=[{"role": "user", "content": "Hello"}],
)
Kimi K3
Reasoning model · OpenAI compatible
⚠ Base URL stops at https://tryaiapi.com/v1. OpenAI-compatible clients append /chat/completions automatically — do not add another /v1 or /chat/completions yourself, or it becomes /v1/v1/chat/completions and 404s
⚠ Kimi K3 always has reasoning (thinking) enabled and it cannot be turned off; reasoning content is billed as output tokens
from openai import OpenAI
client = OpenAI(base_url="https://tryaiapi.com/v1", api_key="your-tryaiapi-key")
resp = client.chat.completions.create(
model="kimi-k3",
reasoning_effort="low",
messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)
# reasoning_effort: "low" | "high" | "max" (default max — no "medium" tier, unlike some OpenAI reasoning models)
Video model API
Seedance / Video tasks
# Standard HTTP call: submit a task, then poll poll_urlcurl https://tryaiapi.com/videos/v1/videos/generations \
-H"Authorization: Bearer your-tryaiapi-key" \
-H"Content-Type: application/json" \
-d'{"model":"doubao-seedance-2.0","prompt":"A product video","duration":5,"resolution":"480p","aspect_ratio":"16:9"}'
Codex CLI
ChatGPT series (Responses API)
⚠ base_url must stop at /v1 — do not add /chat/completions, or Codex will build a bad path and return 404
⚠ Use model gpt-5.5. Codex uses the Responses API (not chat/completions) — declare wire_api = "responses" in config.toml
# ~/.codex/config.toml
model = "gpt-5.5"
model_provider = "tryaiapi"
[model_providers.tryaiapi]
name = "Try AI API"
base_url = "https://tryaiapi.com/v1"
wire_api = "responses"
env_key = "TRYAIAPI_KEY"
export TRYAIAPI_KEY="sk-your-api-key"codex
Codex automatic approval (compatibility mode)
We map codex-auto-review requests to GPT-5.6 Terra and bill them at our Terra rates. This affects automatic approval only; your selected chat and coding model stays unchanged.
Automatic approval defaults to Low reasoning effort. A backup is attempted only when the service request fails; an explicit denial is not retried with another model to seek approval.
You can configure a different reviewer model in your client. Luna has limited supply on this service and has no backup when that supply is exhausted, so we do not recommend it for automatic approval that needs continuous availability.
To confirm actions yourself, select manual approval in Codex.
opencode
Claude + ChatGPT + Grok
⚠ options.baseURL must include /v1 — @ai-sdk/openai-compatible appends /chat/completions directly and does not add /v1 for you
# Set the env var, then run /connect to store the credential under provider id "tryaiapi"export TRYAIAPI_KEY="your-tryaiapi-key"opencode# In the TUI: /connect → Other → paste your key under provider id "tryaiapi"# Then /models to pick one of the models configured above
Yes. Responses pass through the upstream native fields (Anthropic's request_id, OpenAI's id and system_fingerprint). Text requests store no prompts or completions; see the transparency page for the full boundary.
How is billing handled?
Text models are billed by token usage; video models are billed by task, duration, and upstream model. Log in to the console to see real-time balance and usage detail, filterable by model, date, or key. Bank transfer and VAT invoice are supported.
Do you store my prompts and responses?
Text prompts and responses are not stored. Video models are async tasks — task parameters, status, cost, result URL, and failure reason are kept for task tracking and billing. See the transparency page for the full boundary.
Do you support streaming?
Text models support Anthropic-native SSE streaming and OpenAI-compatible streaming — set "stream": true in the request. Video models are not streaming responses; after submission, prefer the response's poll_url. Its current canonical path is /videos/v1/videos/jobs/{job_id}.
How do I call video models?
Use the same API key to call POST /videos/v1/videos/generations. The response returns job_id and poll_url. After the task completes, check the polling response or "Video Model Usage" for the result, download URL, and failure reason.
How do I enable Extended Thinking or reasoning_effort?
The platform provides only official standard model IDs — suffix variants like -thinking/-high/-low are not offered. Reasoning depth is controlled via API parameters:
Anthropic Claude: add "thinking": {"type": "enabled", "budget_tokens": 10000} to the request body (budget: 1024–100000 tokens). max_tokens must exceed budget_tokens. Supported models: claude-opus-4-7, claude-opus-4-8, and others.
OpenAI (reasoning models): add "reasoning_effort": "high" to the request body (options: low/medium/high). Supported models: gpt-5.5 and others — check GET /v1/models to confirm.
💡 Prompt Caching: Claude models support prompt caching, saving up to ~90% on input cost for repeated long context (system prompts, agent loops, codebase context, etc). To enable: use the Anthropic-native /v1/messages format and mark cache_control breakpoints in the messages or system prompt. Note: the OpenAI-compatible /v1/chat/completions format does not support Claude prompt caching — every request is billed at full input price.
How is this different from calling Anthropic / OpenAI directly?
The text endpoints are wire-compatible with Anthropic / OpenAI, including streaming and tool calling. Video models use the Try AI API async task endpoint. One key, one balance, and one usage record across both, plus CNY bank transfer and VAT invoices.