---
name: tryaiapi
description: Configure and call Try AI API (tryaiapi.com) unified LLM, image, and video gateway for Claude Code, Codex CLI, Antigravity, and OpenAI/Anthropic/Gemini SDKs.
homepage: https://tryaiapi.com
docs: https://tryaiapi.com/docs/
catalog: https://tryaiapi.com/catalog.json
pricing: https://tryaiapi.com/api/pricing
openapi: https://tryaiapi.com/docs/openapi.json
llms: https://tryaiapi.com/llms.txt
updated: 2026-11-26
---

# Try AI API — Agent Setup & Integration Skill

You are helping the user configure or integrate **Try AI API** (`https://tryaiapi.com`), a unified gateway covering live text, image, and video models across Anthropic, OpenAI, Google, ByteDance, and MiniMax with a single API key and single USD balance. `https://tryaiapi.com` supports direct access from mainland China and globally; for lower latency from US/overseas servers on text and image requests, you may also use `https://us.tryaiapi.com` with the exact same API key and balance.

## 1. Safety & Secret Hygiene (Always Follow)

1. **Never commit or echo API keys** into git repositories, logs, screenshots, or public files. Store keys in environment variables (`TRYAIAPI_KEY`, `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`) or local user-only config files (`chmod 600`).
2. **Ask the user for their API key only if not already set in the environment.** Users obtain or create keys at `https://tryaiapi.com/sign-in`. When creating a key in the console, keep the group set to the default `auto` so requests route automatically by model.
3. **Verify connectivity for free first** using `GET /v1/user/balance` (read-only, zero cost) before sending any billable generation request.
4. **Never hardcode prices from memory.** Always query live prices from `GET https://tryaiapi.com/api/pricing` or full specs from `GET https://tryaiapi.com/catalog.json`.

---

## 2. Protocol & Endpoint Routing Matrix

Use the exact protocol for each model family — do **not** mix endpoints:

| Model Family | Method & Path | Required Headers | Notes |
|---|---|---|---|
| **Anthropic (Claude)** | `POST /v1/messages` | `Authorization: Bearer $TRYAIAPI_KEY` (or `x-api-key`), `anthropic-version: 2023-06-01`, `Content-Type: application/json` | Native Anthropic Messages API; `ANTHROPIC_BASE_URL` has **no** `/v1` suffix |
| **OpenAI & Google Text (Chat)** | `POST /v1/chat/completions` | `Authorization: Bearer $TRYAIAPI_KEY`, `Content-Type: application/json` | OpenAI-compatible Chat Completions; `OPENAI_BASE_URL` **includes** `/v1` |
| **OpenAI Responses (Codex CLI)** | `POST /v1/responses` | `Authorization: Bearer $TRYAIAPI_KEY`, `Content-Type: application/json` | OpenAI Responses API (`wire_api = "responses"` in Codex CLI); `OPENAI_BASE_URL` **includes** `/v1` |
| **OpenAI Image** (`gpt-image-*`) | `POST /v1/images/generations` | `Authorization: Bearer $TRYAIAPI_KEY`, `Content-Type: application/json` | OpenAI-compatible image generation |
| **Google Image** (`gemini-*-image`, `gemini-nano-banana-2.1`) | `POST /v1beta/models/{model}:generateContent` | `Authorization: Bearer $TRYAIAPI_KEY`, `Content-Type: application/json` | **Do NOT use `/v1/images/generations`** for Gemini image models. Also supports `POST /v1/chat/completions` (image returned inside message content) |
| **Video Generation** (`doubao-seedance-*`, `MiniMax-H3`) | `POST /videos/v1/videos/generations` | `Authorization: Bearer $TRYAIAPI_KEY`, `Content-Type: application/json` | Async workflow: `estimate` → `submit` → poll `GET /videos/v1/videos/jobs/{job_id}` → download |
| **Balance Check (Free)** | `GET /v1/user/balance` | `Authorization: Bearer $TRYAIAPI_KEY` | Read-only, zero charge; returns USD balance matching Console |
| **Model Discovery** | `GET /v1/models` | `Authorization: Bearer $TRYAIAPI_KEY` | Live list of model IDs callable by this key |

**Streaming & Tool Calling**: All text endpoints (`/v1/messages`, `/v1/chat/completions`, `/v1/responses`) support SSE streaming (`"stream": true`) and native tool/function calling per each protocol's schema. Check `/catalog.json` for per-model context limits and capabilities.

---

## 3. Auto-Configure Clients

### A. Claude Code

Base URL MUST be `https://tryaiapi.com` (no `/v1` suffix).

Shell environment (`~/.zshrc` or `~/.bashrc`):
```bash
export ANTHROPIC_BASE_URL="https://tryaiapi.com"
export ANTHROPIC_API_KEY="YOUR_TRYAIAPI_KEY"
```

Or `~/.claude/settings.json` (merge into existing `env` object without overwriting unrelated keys):
```json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://tryaiapi.com",
    "ANTHROPIC_API_KEY": "YOUR_TRYAIAPI_KEY"
  }
}
```

### B. Codex CLI

Base URL MUST include `/v1`: `https://tryaiapi.com/v1`.

Shell environment:
```bash
export OPENAI_BASE_URL="https://tryaiapi.com/v1"
export OPENAI_API_KEY="YOUR_TRYAIAPI_KEY"
```

Or `~/.codex/config.toml` (add a custom provider without deleting existing profiles):
```toml
[model_providers.tryaiapi]
name = "Try AI API"
base_url = "https://tryaiapi.com/v1"
env_key = "TRYAIAPI_KEY"
wire_api = "responses"
```

### C. OpenAI-Compatible Agents, Clients & SDKs (Cursor, Cline, WorkBuddy, Antigravity, OpenClaw, etc.)

For any OpenAI-compatible client or AI agent, configure these three fields:
- **Base URL**: `https://tryaiapi.com/v1` (or `https://tryaiapi.com` for native Anthropic `/v1/messages` clients)
- **API Key**: `$TRYAIAPI_KEY`
- **Model ID**: pick any live ID from `GET /v1/models` or `GET /catalog.json` (e.g., `gpt-6.2-sol`, `claude-sonnet-5-5`, `gemini-4-neon`)

**Python (`openai` SDK):**
```python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://tryaiapi.com/v1",
    api_key=os.environ["TRYAIAPI_KEY"],
)
resp = client.chat.completions.create(
    model="gpt-6.2-sol",
    messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)
```

**Python (`anthropic` SDK):**
```python
import os
import anthropic

client = anthropic.Anthropic(
    base_url="https://tryaiapi.com",
    api_key=os.environ["TRYAIAPI_KEY"],
)
msg = client.messages.create(
    model="claude-sonnet-5-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}],
)
print(msg.content[0].text)
```

---

## 4. Smoke Test (Run After Configuring)

### A. Free Auth & Balance Check (Zero Cost)

Always verify auth and balance first without spending credits:

```bash
curl -sS https://tryaiapi.com/v1/user/balance \
  -H "Authorization: Bearer $TRYAIAPI_KEY"
```

Expected HTTP `200` with JSON balance payload. If `401`, the API key is missing, revoked, or malformed. If `402`, top up balance at `https://tryaiapi.com/sign-in`.

### B. Minimal Chat Verification

After the free balance check succeeds, run a minimal low-token chat request to confirm end-to-end model routing:

```bash
curl -sS https://tryaiapi.com/v1/chat/completions \
  -H "Authorization: Bearer $TRYAIAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"gemini-4-neon","messages":[{"role":"user","content":"Reply with OK"}],"max_tokens":16}'
```

Expected HTTP `200` with `choices[0].message.content`.

### C. Error Codes & Retry Discipline

- **`401`**: API key is missing, revoked, or malformed — verify key in Console.
- **`402`**: Insufficient balance — top up at `https://tryaiapi.com/sign-in`.
- **`404`**: Most commonly caused by a Base URL `/v1` suffix mismatch (Claude Code must omit `/v1`; Codex/OpenAI clients must include `/v1`) or a model ID not listed in `GET /v1/models`.
- **`429` / `503`**: Rate-limited or transient upstream overload — retry with exponential backoff (e.g., 1s → 2s → 4s, respecting `Retry-After` if present); never tight-loop retry.

---

## 5. Active Model IDs (Snapshot — Always Verify Live via `/v1/models` or `/catalog.json`)

- **Text — Anthropic (4 of 13 text models)**: `claude-fable-5-2`, `claude-opus-5-5`, `claude-sonnet-5-5`, `claude-haiku-5-5`
- **Text — OpenAI (5 of 13 text models)**: `gpt-6.2-astra`, `gpt-6.2-sol`, `gpt-6-astra`, `gpt-6-sol`, `gpt-6-luna`
- **Text — Google (4 of 13 text models)**: `gemini-4-neon`, `gemini-4-carbon`, `gemini-4-argon`, `gemini-4-hydrogen`
- **Image — OpenAI (`/v1/images/generations`)**: `gpt-image-2.6-sunburst`, `gpt-image-2.6-flare`, `gpt-image-2.6-sunburst-oai`, `gpt-image-2.6-flare-oai`, `gpt-image-2.5-sunburst-oai`, `gpt-image-2.5-flare-oai`
- **Image — Google (`/v1beta/models/{id}:generateContent`)**: `gemini-3-pro-image`, `gemini-nano-banana-2.1`, `gemini-3.1-flash-image`
- **Video — ByteDance & MiniMax (`/videos/v1/videos/generations`)**: `doubao-seedance-2.5`, `doubao-seedance-2.0`, `doubao-seedance-2.0-fast`, `MiniMax-H3`

### Video Async Workflow
1. Optional pre-submit quote: `POST /videos/v1/videos/generations/estimate`
2. Submit job: `POST /videos/v1/videos/generations` → returns `job_id`
3. Poll status: `GET /videos/v1/videos/jobs/{job_id}` until `succeeded` or `failed`
4. Full video API spec (reference images, asset library, error codes): `https://tryaiapi.com/docs/video-model/index.md.txt`

---

## 6. Machine-Readable Discovery Endpoints

Prefer plain-text Markdown and JSON endpoints over scraping HTML:

- `https://tryaiapi.com/llms.txt` — Concise site & model index
- `https://tryaiapi.com/catalog.json` — Full structured model catalog & capabilities
- `https://tryaiapi.com/api/pricing` — Real-time live pricing
- `https://tryaiapi.com/docs/openapi.json` — OpenAPI 3.x specification
- `https://tryaiapi.com/docs/index.md.txt` — Full API documentation (Markdown, ZH)
- `https://tryaiapi.com/en/docs/index.md.txt` — Full API documentation (Markdown, EN)
- `https://tryaiapi.com/docs/image-model/index.md.txt` — Image generation guide (Markdown, ZH)
- `https://tryaiapi.com/en/docs/image-model/index.md.txt` — Image generation guide (Markdown, EN)
- `https://tryaiapi.com/docs/coding-agents/index.md.txt` — Claude Code & Codex CLI setup guide (Markdown, ZH)
- `https://tryaiapi.com/en/docs/coding-agents/index.md.txt` — Claude Code & Codex CLI setup guide (Markdown, EN)
- `https://tryaiapi.com/docs/video-model/index.md.txt` — Video generation spec (Markdown, ZH)
- `https://tryaiapi.com/en/docs/video-model/index.md.txt` — Video generation spec (Markdown, EN)
- `https://tryaiapi.com/models/index.md.txt` — Model market snapshot (Markdown, ZH)
- `https://tryaiapi.com/en/models/index.md.txt` — Model market snapshot (Markdown, EN)
- `https://tryaiapi.com/transparency/index.md.txt` — Transparency & data retention scope (Markdown, ZH)
- `https://tryaiapi.com/en/transparency/index.md.txt` — Transparency & data retention scope (Markdown, EN)
