> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ascn.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Instructions for AI

> One click, and your AI assistant knows how to work with ASCN Router.

Integrating ASCN Router with Cursor, Claude Code, ChatGPT or another AI assistant? Copy the instructions below with one click (the copy icon in the top-right corner of the block) and paste them into the chat. Your assistant gets everything it needs to write working code.

```text Instructions for AI theme={null}
You are integrating ASCN Router — an OpenAI-compatible API in front of models from OpenAI, Anthropic, Google, DeepSeek, xAI, Qwen, Mistral and others.

CONNECTION
- Base URL: https://b2b.api.ascn.ai/api/ai-gateway/v1
- Auth: send the API key in the header "X-API-KEY: <key>". Read the key from the env var ASCN_API_KEY. Never hard-code it or ship it to the client.
- With the official OpenAI SDK, set base_url to the URL above, pass the key as api_key AND add it to default headers as X-API-KEY.
  Python: OpenAI(base_url=URL, api_key=key, default_headers={"X-API-KEY": key})
  Node:   new OpenAI({ baseURL: URL, apiKey: key, defaultHeaders: { "X-API-KEY": key } })

MODELS
- Model names look like "vendor/model", e.g. "openai/gpt-4o-mini", "anthropic/claude-haiku-4.5", "deepseek/deepseek-v4-flash".
- Get the live list from GET /v1/models. Each entry has id, kind (text | image | video | music | audio), context_length, input_modalities and pricing. Do not hard-code a model list.

TEXT
- POST /v1/chat/completions — standard OpenAI Chat Completions; tools, tool_choice, response_format, seed, stop etc. are forwarded to the model.
- POST /v1/responses — OpenAI Responses API, but responses are NOT stored: previous_response_id is not supported, send the full history in input.
- Use "stream": true for long answers; non-streamed long answers may fail with code streaming_required.
- Reasoning models spend max_tokens on hidden reasoning: set max_tokens >= 2000 for them.

MEDIA (images, video, music, speech) — asynchronous jobs
1. POST /v1/{images|videos|music|audio}/jobs with a model of that kind -> returns { id, status: "pending", estimated_cost }.
2. Poll GET /v1/{kind}/jobs/{id} every 3-5 s until status is "completed" or "failed".
3. Download each output[i].url (/v1/{kind}/jobs/{id}/content?index=N) with the same X-API-KEY header. Images/video are kept 7 days; download music/speech right away.
- Images: model, prompt, size ("16:9", "1k", "WIDTHxHEIGHT"), input_images (for editing), output_format.
- Video: model, prompt, duration, aspect_ratio, resolution, image_url (image-to-video), audio.
- Music: model, prompt, lyrics, style, title, instrumental.
- Audio: model, text + voice (speech), dialogue, audio_url (voice isolation).

ERRORS
- OpenAI error envelope plus status_code and request_id: {"error": {"message", "type", "code"}, "status_code", "request_id"}.
- Retry 429 rate_limited (after Retry-After), 502 backend_error, 503. Do not retry 400/404 without changing the request.
- 402 insufficient_balance: the max possible cost (prompt + max_tokens, 4096 if unset) is held before the request runs; set max_tokens when the balance is low.

BILLING
- Charged in USD, counted in micro-dollars (1 µ$ = $0.000001): input_tokens x input price + output_tokens x output price, prices per million tokens from GET /v1/models. Failed media jobs cost nothing.

Full docs: https://docs.ascn.ai/llms-full.txt
```

## Open a page in AI

Every docs page has a menu next to the title: copy the page as Markdown, or open it straight in ChatGPT, Claude, Perplexity or Cursor.

## The whole docs in one file

* [`/llms.txt`](/llms.txt) — a short index of pages for AI.
* [`/llms-full.txt`](/llms-full.txt) — the entire documentation in one file. Give the link to your assistant when it needs full context.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.