Text call · cURL
curl https://tryaiapi.com/v1/chat/completions \ -H "Authorization: Bearer $TRYAIAPI_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "claude-sonnet-4-6", "messages": [ {"role": "user", "content": "Hello"} ] }'
Visual model task · cURL
curl 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", "duration": 5, "resolution": "480p", "aspect_ratio": "16:9" }'
Models

One key for text and visual models

Use this section for endpoint rules and model ID lookup. The full live catalog is on the models page.

Live model catalog

Model IDs are sourced from GET /v1/models. Live pricing, groups, and available endpoints live on the model market; the docs page keeps only integration rules and key entry points.

API definition: /docs/openapi.json. Model details use live /v1/models and the model market as the source of truth.

curl · List models
curl https://tryaiapi.com/v1/models \ -H "Authorization: Bearer $TRYAIAPI_KEY"
Quick Start

Integrate in three steps

STEP 01

Request an API key

Open the console to create an API key. Bank transfer and VAT invoice supported.

STEP 02

Choose the endpoint

Text models use an SDK base URL swap. Visual models use /videos/v1/videos/generations to submit async tasks.

STEP 03

Review results and usage

Text calls return in real time; visual tasks are polled until completion. Usage records can be exported for reconciliation.

API Endpoints

Endpoints

GET

/v1/models

Query current callable model IDs before integration.

POST

/v1/chat/completions

OpenAI-compatible endpoint for SDKs, agents, and tools.

POST

/v1/messages

Anthropic Messages-compatible endpoint for Claude clients and SDKs.

POST

/videos/v1/videos/generations

Submit a visual generation task and receive a job ID and polling URL.

GET

/videos/v1/videos/generations/{task_id}

Poll task status, failure reason, and download URLs.

Code Examples · Advanced

Advanced scenario examples

Advanced text capabilities and visual model async task examples — cURL / Python / JavaScript shown for each scenario.

cURL · streaming response (SSE)
curl -N https://tryaiapi.com/v1/chat/completions \ -H "Authorization: Bearer $TRYAIAPI_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "claude-sonnet-4-6", "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-4-6", 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-4-6", 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 · visual model async task
# 1. Submit job curl 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" }' # 2. Poll result curl https://tryaiapi.com/videos/v1/videos/generations/$JOB_ID \ -H "Authorization: Bearer $TRYAIAPI_KEY"
Python · visual 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"] while True: 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 · visual 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; } await new Promise((resolve) => setTimeout(resolve, 5000)); }
Video task parameter reference

Video task parameter reference

Parameter Type Description
model string doubao-seedance-2.0 or doubao-seedance-2.0-fast
prompt string Text prompt, required
duration integer Duration in seconds, range 4–15
resolution string 480p / 720p / 1080p (fast does not support 1080p)
image_urls array ≤9 Reference images. Each item is 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 accompany role:"reference_image" images or video_urls; first/last-frame images cannot be combined with audio
generate_audio boolean Whether output includes audio, default false
cURL · with reference image and audio
curl https://tryaiapi.com/videos/v1/videos/generations \ -H "Authorization: Bearer $TRYAIAPI_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "doubao-seedance-2.0", "prompt": "Product showcase video, soft lighting, slow push-in", "duration": 5, "resolution": "720p", "image_urls": [ {"url": "https://example.com/product.jpg", "role": "reference_image"} ], "audio_urls": ["https://example.com/bgm.mp3"], "generate_audio": true }'

Billing: settled per task; on success, reconciled against upstream usage.total_tokens with credit/charge adjustment; failures are fully refunded.

cURL · tool calling (Function Calling)
curl https://tryaiapi.com/v1/chat/completions \ -H "Authorization: Bearer $TRYAIAPI_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "claude-sonnet-4-6", "messages": [{"role": "user", "content": "What's the weather like in Hangzhou?"}], "tools": [{ "type": "function", "function": { "name": "get_weather", "parameters": { "type": "object", "properties": {"city": {"type": "string"}} } } }] }'
Python · tool calling
from openai import OpenAI client = OpenAI(base_url="https://tryaiapi.com/v1", api_key="$TRYAIAPI_KEY") resp = client.chat.completions.create( model="claude-sonnet-4-6", messages=[{"role": "user", "content": "What's the weather like in Hangzhou?"}], tools=[{ "type": "function", "function": { "name": "get_weather", "parameters": { "type": "object", "properties": {"city": {"type": "string"}}, }, }, }], ) print(resp.choices[0].message.tool_calls)
JavaScript · tool calling
import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://tryaiapi.com/v1", apiKey: process.env.TRYAIAPI_KEY, }); const resp = await client.chat.completions.create({ model: "claude-sonnet-4-6", messages: [{ role: "user", content: "What's the weather like in Hangzhou?" }], tools: [{ type: "function", function: { name: "get_weather", parameters: { type: "object", properties: { city: { type: "string" } }, }, }, }], }); console.log(resp.choices[0].message.tool_calls);

The platform provides only official standard model IDs. Suffix variants like -thinking, -high, or -low are not available. 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 to 100000) # max_tokens must exceed budget_tokens to leave room for output # Supported models: claude-opus-4-7, claude-opus-4-8, etc.
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) # Supported for 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)
SDK Configuration

Client SDK configuration examples

Claude Code

All Claude models
# Set environment variables, then launch export ANTHROPIC_BASE_URL=https://tryaiapi.com export ANTHROPIC_API_KEY=your-tryaiapi-key claude

Cursor

Claude + ChatGPT
# Settings → Models → Override OpenAI Base URL Base URL: https://tryaiapi.com API Key: your-tryaiapi-key # Claude: use claude-sonnet-4-6 directly. ChatGPT IDs: query /v1/models first.

Anthropic Python SDK

All Claude models
import anthropic client = anthropic.Anthropic( base_url="https://tryaiapi.com", api_key="your-tryaiapi-key", ) msg = client.messages.create( model="claude-sonnet-4-6", max_tokens=1024, messages=[{"role": "user", "content": "Hello"}], )

OpenAI Python SDK

Claude + ChatGPT
# Swap provider by changing the model name from 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-4-6", messages=[{"role": "user", "content": "Hello"}], ) # ChatGPT — same client resp = client.chat.completions.create( model="gpt-5.5", messages=[{"role": "user", "content": "Hello"}], )

Visual model API

Seedance / Video tasks
# Standard HTTP call: submit a task, then poll poll_url curl 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

Claude + ChatGPT
# Codex CLI uses the OpenAI-compatible format export OPENAI_BASE_URL=https://tryaiapi.com/v1 export OPENAI_API_KEY=your-tryaiapi-key codex

LangChain

All Claude models
from langchain_anthropic import ChatAnthropic llm = ChatAnthropic( base_url="https://tryaiapi.com", api_key="your-tryaiapi-key", model="claude-sonnet-4-6", )
FAQ

Frequently asked questions

How do I verify I am using the real model?
Each response carries the upstream native fields (Anthropic request_id, OpenAI id and system_fingerprint), identical to a direct upstream call. Visit the transparency page to inspect the database schema and confirm we do not store prompt or response bodies.
How is billing handled?
Text models are billed by token usage. Visual models are billed by task, duration, and upstream model. The console shows real-time balance, usage detail, and exports grouped by model / date / key. Bank transfer and VAT invoice are supported.
Do you store my prompts and responses?
The text channel does not persist prompt or response bodies in the regular database layer. Visual models are async tasks: task parameters, status, cost, result URLs, and failure reasons are kept for task tracking and billing. The full boundary is on the transparency page.
Do you support streaming?
Text models support Anthropic-native SSE streaming and OpenAI-compatible streaming — set "stream": true in the request. Visual models are not streaming responses; submit a task, then poll /videos/v1/videos/generations/{task_id} for the result.
How do I call visual models?
Use the same API key to call POST /videos/v1/videos/generations. The response returns job_id and poll_url. After completion, the polling response or "Visual model usage detail" shows the result, download URL, and failure reason.
How do I enable Extended Thinking or adjust reasoning effort?
The platform provides only official standard model IDs. Suffix variants like -thinking, -high, or -low are not available. 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, etc.
  • OpenAI (reasoning models): Add "reasoning_effort": "high" to the request body (options: low / medium / high). Supported models: gpt-5.5, etc. Check GET /v1/models for current availability.
See full examples in Code Examples → Extended Thinking.
How does this differ from calling Anthropic / OpenAI directly?
The text channel preserves the Anthropic / OpenAI compatible protocol surface (streaming, tool calling). Visual models are unified across multiple upstream providers through the Try AI API async task endpoint. The difference: a single key, balance, and usage record across all of them, plus CNY bank transfer and VAT invoice support.