Главная / LLM API / Инструкция по настройке
Инструкции по настройке

Настройте каждый клиент правильно

Выберите клиент в левой колонке, чтобы увидеть полную инструкцию. Примеры ниже используют ваш текущий API-ключ и реальный базовый URL системы.

Вернуться к тарифам Консоль

Что подготовить перед настройкой

  • Пополните баланс и убедитесь, что API-ключ создан в консоли AI API.
  • Используйте правильный базовый URL для каждого клиента: где-то нужен `/v1`, где-то нет.
  • Выбирайте модель, которая в данный момент активна на странице тарифов, избегая моделей с отключённым маршрутом.
  • Если клиент поддерживает настраиваемые endpoints, всегда используйте HTTPS-endpoint текущего сайта.

Правила базового URL

  • Клиенты, совместимые с OpenAI: используйте базовый URL с `/v1`.
  • Переменная окружения Claude Code `ANTHROPIC_BASE_URL`: используйте корневой домен без `/v1`.
API reference

Endpoints and commands

Open an endpoint to see its complete curl command. The list stays compact instead of rendering every command at once.

Text / hội thoại

chat/completionsPOST

OpenAI-compatible chat; messages, tools and optional stream=true.

https://api.xah.io/v1/chat/completions

Complete command
API_KEY="YOUR_CKEY_API_KEY"

curl https://api.xah.io/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "MODEL",
  "messages": [{"role": "user", "content": "Hello"}],
  "stream": false
}'
completionsPOST

Legacy prompt completion; use only when this capability is enabled.

https://api.xah.io/v1/completions

Complete command
API_KEY="YOUR_CKEY_API_KEY"

curl https://api.xah.io/v1/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "MODEL",
  "prompt": "Hello",
  "max_tokens": 256
}'
responsesPOST

Responses-style request; input/output follows the enabled upstream contract.

https://api.xah.io/v1/responses

Complete command
API_KEY="YOUR_CKEY_API_KEY"

curl https://api.xah.io/v1/responses \
  -H "Authorization: Bearer $API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "MODEL",
  "input": "Hello"
}'
messagesPOST

Anthropic Messages format. Send anthropic-version: 2023-06-01 and max_tokens.

https://api.xah.io/v1/messages

Complete command
API_KEY="YOUR_CKEY_API_KEY"

curl https://api.xah.io/v1/messages \
  -H "Authorization: Bearer $API_KEY" \
  -H 'Content-Type: application/json' \
  -H 'anthropic-version: 2023-06-01' \
  -d '{
  "model": "MODEL",
  "max_tokens": 1024,
  "messages": [{"role": "user", "content": "Hello"}]
}'

Images

images/generationsPOST

Text-to-image. Use only fields documented by the selected image model: prompt, n, size, quality, response_format, etc.

https://api.xah.io/v1/images/generations

Complete command
API_KEY="YOUR_CKEY_API_KEY"

curl https://api.xah.io/v1/images/generations \
  -H "Authorization: Bearer $API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "MODEL",
  "prompt": "A red fox in snow",
  "n": 1,
  "size": "1024x1024"
}'
images/generations · image-to-imagePOST

Tạo ảnh từ ảnh cũng gọi cùng endpoint images/generations. Gửi ảnh theo field mà model/upstream đã công bố trong payload template; ví dụ dưới dùng image_url là contract của model mẫu.

https://api.xah.io/v1/images/generations

Complete command
API_KEY="YOUR_CKEY_API_KEY"

curl https://api.xah.io/v1/images/generations \
  -H "Authorization: Bearer $API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "MODEL",
  "prompt": "Turn the reference into a watercolor illustration",
  "image_url": "https://example.com/reference.png",
  "n": 1,
  "size": "1024x1024"
}'
images/editsPOST multipart

Image-to-image edit/generation. image is multipart; prompt and mask depend on the selected model contract.

https://api.xah.io/v1/images/edits

Complete command
API_KEY="YOUR_CKEY_API_KEY"

curl https://api.xah.io/v1/images/edits \
  -H 'Authorization: Bearer API_KEY' \
  -F 'model=MODEL' \
  -F 'prompt=Make it brighter' \
  -F '[email protected]'
images/variationsPOST multipart

Create variations from an input image. image is multipart; do not send JSON/base64 unless the selected upstream documents it.

https://api.xah.io/v1/images/variations

Complete command
API_KEY="YOUR_CKEY_API_KEY"

curl https://api.xah.io/v1/images/variations \
  -H 'Authorization: Bearer API_KEY' \
  -F 'model=MODEL' \
  -F '[email protected]'

Audio

audio/speechPOST

Text-to-speech. The successful response is binary audio; save the response body, do not call response.json().

https://api.xah.io/v1/audio/speech

Complete command
API_KEY="YOUR_CKEY_API_KEY"

curl https://api.xah.io/v1/audio/speech \
  -H "Authorization: Bearer $API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "MODEL",
  "input": "Hello from CKEY",
  "voice": "alloy",
  "response_format": "mp3"
}'
audio/transcriptionsPOST multipart

Speech-to-text. Send a multipart file plus model and any documented language/prompt fields.

https://api.xah.io/v1/audio/transcriptions

Complete command
API_KEY="YOUR_CKEY_API_KEY"

curl https://api.xah.io/v1/audio/transcriptions \
  -H 'Authorization: Bearer API_KEY' \
  -F 'model=MODEL' -F '[email protected]'
audio/translationsPOST multipart

Translate speech from an audio file. Send multipart/form-data.

https://api.xah.io/v1/audio/translations

Complete command
API_KEY="YOUR_CKEY_API_KEY"

curl https://api.xah.io/v1/audio/translations \
  -H 'Authorization: Bearer API_KEY' \
  -F 'model=MODEL' -F '[email protected]'

Video (task / async)

v1/videosPOST + GET

OpenAI-compatible Video API V1. POST creates a job at /v1/videos/generations; poll GET /v1/videos/{JOB_ID}. Use seconds for the V1 contract.

https://api.xah.io/v1/videos/generations

Complete command
API_KEY="YOUR_CKEY_API_KEY"

curl https://api.xah.io/v1/videos/generations \
  -H "Authorization: Bearer $API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "MODEL",
  "prompt": "A gentle camera move across a mountain",
  "seconds": 8
}

# Poll: GET https://api.xah.io/v1/videos/JOB_ID'
v2/video_generationPOST + GET + DELETE

CKEY public Task API V2. POST creates a task; poll GET /v2/query/video_generation/{JOB_ID}; cancel DELETE /v2/video_generation/{JOB_ID}. Use duration for the V2 contract; do not change the route to V1.

https://api.xah.io/v2/video_generation

Complete command
API_KEY="YOUR_CKEY_API_KEY"

curl https://api.xah.io/v2/video_generation \
  -H "Authorization: Bearer $API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "MODEL",
  "content": [{"type": "text", "text": "A gentle camera move across a mountain"}],
  "duration": 6,
  "ratio": "16:9"
}

# Poll: GET https://api.xah.io/v2/query/video_generation/JOB_ID
# Cancel: DELETE https://api.xah.io/v2/video_generation/JOB_ID'

Embeddings / ranking / safety / search

embeddingsPOST

Convert one string or an array of strings to vectors.

https://api.xah.io/v1/embeddings

Complete command
API_KEY="YOUR_CKEY_API_KEY"

curl https://api.xah.io/v1/embeddings \
  -H "Authorization: Bearer $API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "MODEL",
  "input": ["first text", "second text"]
}'
rerankPOST

Rank documents for a query. query and documents are required; top_n must not exceed document count.

https://api.xah.io/v1/rerank

Complete command
API_KEY="YOUR_CKEY_API_KEY"

curl https://api.xah.io/v1/rerank \
  -H "Authorization: Bearer $API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "MODEL",
  "query": "latest AI news",
  "documents": ["doc A", "doc B"],
  "top_n": 2
}'
moderationsPOST

Classify input using the enabled moderation model.

https://api.xah.io/v1/moderations

Complete command
API_KEY="YOUR_CKEY_API_KEY"

curl https://api.xah.io/v1/moderations \
  -H "Authorization: Bearer $API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "MODEL",
  "input": "Text to classify"
}'
searchPOST

Provider/model-specific search contract. Send optional fields only when the selected model documents them.

https://api.xah.io/v1/search

Complete command
API_KEY="YOUR_CKEY_API_KEY"

curl https://api.xah.io/v1/search \
  -H "Authorization: Bearer $API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "MODEL",
  "query": "latest AI news",
  "max_results": 5
}'

Native provider routes

geminiPOST

Google Gemini native format. Streaming uses :streamGenerateContent?alt=sse, not an invented stream body field.

https://api.xah.io/v1beta/models/MODEL:generateContent

Complete command
API_KEY="YOUR_CKEY_API_KEY"

curl https://api.xah.io/v1beta/models/MODEL:generateContent \
  -H "Authorization: Bearer $API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "contents": [{"role": "user", "parts": [{"text": "Hello"}]}]
}'
ollamaPOST

Ollama native chat format.

https://api.xah.io/api/chat

Complete command
API_KEY="YOUR_CKEY_API_KEY"

curl https://api.xah.io/api/chat \
  -H "Authorization: Bearer $API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "MODEL",
  "messages": [{"role": "user", "content": "Hello"}],
  "stream": false
}'
api/generatePOST

Ollama native prompt generation.

https://api.xah.io/api/generate

Complete command
API_KEY="YOUR_CKEY_API_KEY"

curl https://api.xah.io/api/generate \
  -H "Authorization: Bearer $API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "MODEL",
  "prompt": "Hello",
  "stream": false
}'
Contract rule

Both text-to-image and image-to-image use POST /images/generations when that is the model contract. Do not rename the image field: use the payload template/contract of the selected model. Do not substitute images/edits or images/variations for a model that exposes only images/generations.

OpenAI-compatible chat/completions /v1

Cursor

Cursor следует использовать в режиме, совместимом с OpenAI, с собственным API-ключом и базовым URL.

Необходимые значения

Провайдер
OpenAI-compatible
API-ключ
sk-YOUR_API_KEY
Базовый URL
https://api.xah.io/v1
Модель
gpt-5.4
Маршрут
chat/completions
Требование к тарифу
Требуется тариф Cursor, поддерживающий собственные API endpoints.

Рекомендуемые шаги

  1. 1Откройте настройки Cursor и перейдите в раздел AI / Models / API Keys.
  2. 2Включите опцию собственного OpenAI-ключа или собственного провайдера, если в вашей версии Cursor она называется иначе.
  3. 3Вставьте API-ключ и базовый URL из раздела ниже.
  4. 4Выберите предложенную модель или другую активную модель.

Готовый блок конфигурации

Provider: OpenAI-compatible
API Key: sk-YOUR_API_KEY
Base URL: https://api.xah.io/v1
Model: gpt-5.4
Route: chat/completions

Рекомендуемые модели

  • gpt-5.4
  • claude-opus-4.6
  • claude-opus-4.7
  • claude-opus-4.8
  • claude-opus-5
  • claude-sonnet-4.6

Важно

  • Cursor работает в совместимом с OpenAI режиме, поэтому базовый URL должен содержать `/v1`.
  • Если модель не работает в Cursor, попробуйте другую активную модель, совместимую с OpenAI.
  • После сохранения отправьте короткий промпт, чтобы убедиться, что маршрут `chat/completions` работает.
Связаться с поддержкой
Мы всегда готовы вам помочь