Home›Developer Center›OpenRouter API

OpenRouter API

API DocumentationOpenAI ChatGPT APIAnthropic (Claude) APIGoogle Gemini APIGoogle Search APIGoogle News APIOpenRouter APIAPI Pricing
CLI & Agent Guidescc-switch macOScc-switch Windowscc-switch LinuxOpenCode macOSOpenCode WindowsOpenCode LinuxOpenClaw macOSOpenClaw WindowsOpenClaw LinuxHermes Agent macOSHermes Agent WindowsHermes Agent LinuxClaude Code CLI macOSClaude Code CLI WindowsClaude Code CLI LinuxCodex CLI macOSCodex CLI WindowsCodex CLI Linux
MYAI168 API & MCPMYAI168 MCP CLIMYAI168 MCP Web & App
No matching questions on this page.Search the whole site
OpenRouter

OpenRouter API Relay

OpenRouter is an LLM gateway. One key gives access to hundreds of models (OpenAI / Anthropic / Google / Meta / Mistral, etc.) using vendor/model naming.

POST https://www.myai168.com/en/api/openrouter/v1/chat/completions

Chat Completions (OpenAI format compatible).

curl https://www.myai168.com/en/api/openrouter/v1/chat/completions \
  -H "Authorization: Bearer YOUR_DEV_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"anthropic/claude-sonnet-5","messages":[{"role":"user","content":"Hello"}]}'
import requests

r = requests.post(
    "https://www.myai168.com/en/api/openrouter/v1/chat/completions",
    headers={"Authorization": "Bearer YOUR_DEV_KEY"},
    json={"model": "anthropic/claude-sonnet-5", "messages": [{"role": "user", "content": "Hello"}]},
)
print(r.json())

POST https://www.myai168.com/en/api/openrouter/v1/chat/responses

Note: this endpoint is NOT the OpenAI Responses API — the request and response are both in Chat Completions format (same fields as completions above). It behaves the same as completions: both endpoints pre-check your credit balance and return 402 without forwarding when credits run out. For the OpenAI Responses API schema use https://www.myai168.com/en/api/openai/v1/responses instead.

curl https://www.myai168.com/en/api/openrouter/v1/chat/responses \
  -H "Authorization: Bearer YOUR_DEV_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"openai/gpt-5.6-sol","messages":[{"role":"user","content":"Hello"}]}'
import requests

r = requests.post(
    "https://www.myai168.com/en/api/openrouter/v1/chat/responses",
    headers={"Authorization": "Bearer YOUR_DEV_KEY"},
    json={"model": "openai/gpt-5.6-sol", "messages": [{"role": "user", "content": "Hello"}]},
)
print(r.json())

POST https://www.myai168.com/en/api/openrouter/v1/audio/speech

Text-to-speech (routed through OpenRouter to TTS provider). Note: OpenRouter does not offer openai/tts-1 — current TTS model ids are versioned, e.g. openai/gpt-4o-mini-tts-2025-12-15 and mistralai/voxtral-mini-tts-2603; check the official OpenRouter model list.

curl https://www.myai168.com/en/api/openrouter/v1/audio/speech \
  -H "Authorization: Bearer YOUR_DEV_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"openai/gpt-4o-mini-tts-2025-12-15","input":"Hello","voice":"nova"}' \
  --output speech.mp3
import requests

r = requests.post(
    "https://www.myai168.com/en/api/openrouter/v1/audio/speech",
    headers={"Authorization": "Bearer YOUR_DEV_KEY"},
    json={"model": "openai/gpt-4o-mini-tts-2025-12-15", "input": "Hello", "voice": "nova"},
)
with open("speech.mp3", "wb") as f:
    f.write(r.content)

POST https://www.myai168.com/en/api/openrouter/v1/audio/transcriptions

Speech-to-text (multipart upload). OpenRouter's official STT models are openai/whisper-1 / openai/whisper-large-v3 etc. (openai/gpt-4o-transcribe is not listed); this relay accepts openai/whisper-1.

curl https://www.myai168.com/en/api/openrouter/v1/audio/transcriptions \
  -H "Authorization: Bearer YOUR_DEV_KEY" \
  -F file=@audio.mp3 \
  -F model=openai/whisper-1
import requests

with open("audio.mp3", "rb") as f:
    r = requests.post(
        "https://www.myai168.com/en/api/openrouter/v1/audio/transcriptions",
        headers={"Authorization": "Bearer YOUR_DEV_KEY"},
        files={"file": f},
        data={"model": "openai/whisper-1"},
    )
print(r.json())

POST https://www.myai168.com/en/api/openrouter/v1/video/generations

Video generation (depends on supported video models). Note: vendor/some-video-model in the examples is a placeholder, not a runnable model id — the OpenRouter video endpoint is new and the available models are announced by OpenRouter; an unsupported model gets a 4xx from the upstream (never charged).

curl https://www.myai168.com/en/api/openrouter/v1/video/generations \
  -H "Authorization: Bearer YOUR_DEV_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"vendor/some-video-model","prompt":"A cat dancing"}'
import requests

r = requests.post(
    "https://www.myai168.com/en/api/openrouter/v1/video/generations",
    headers={"Authorization": "Bearer YOUR_DEV_KEY"},
    json={"model": "vendor/some-video-model", "prompt": "A cat dancing"},
)
print(r.json())
Request parameters, response format and error codes

Request parameters (chat/completions and chat/responses)

Both endpoints take a Chat Completions format JSON body (chat/responses is not the OpenAI Responses API — it behaves the same as completions). Authenticate with an Authorization: Bearer YOUR_API_KEY header (never place keys in URL query strings).

ParameterTypeRequiredDescription
modelstringrequiredOpenRouter model id in vendor/model form (e.g. anthropic/claude-sonnet-5).
messagesarrayrequiredConversation messages (OpenAI Chat Completions format). role / content are forwarded as-is per the official format (including tool and other roles, and content-part arrays); support depends on the selected model.
streambooleanoptionaltrue streams the response as SSE.
Other official parameters—optionalForwarded to OpenRouter as-is.

Response format

OpenAI Chat Completions compatible: text in choices[0].message.content (streaming deltas in choices[0].delta.content). Billing converts the actual cost reported by OpenRouter into points; non-streaming responses carry X-Cost-Points (points charged) and X-Credits-Remaining (balance after the call) headers, and streaming responses append the same information after the stream ends as SSE comment lines : cost=N / : credits-remaining=M. You can also query your balance any time with GET https://www.myai168.com/en/api/user/get_credits.

Error codes

HTTP statusMeaning
401Missing or invalid API key (repeated failures from the same IP are temporarily blocked).
402Insufficient credits (chat/responses / audio / video endpoints block before forwarding).
400Invalid request body, or an audio-endpoint model with no pricing info ("No pricing info! Please use other models!").
502Upstream vendor error — never charged.

No points are ever charged on errors (including when the vendor returns no usage / cost info).

‹ Previous page: Google News APINext page: API Pricing ›
↑
Question link copied.

Other FAQ pages

API Documentation

  • OpenAI ChatGPT API
  • Anthropic (Claude) API
  • Google Gemini API
  • Google Search API
  • Google News API
  • API Pricing

CLI & Agent Guides

  • cc-switch macOS
  • cc-switch Windows
  • cc-switch Linux
  • OpenCode macOS
  • OpenCode Windows
  • OpenCode Linux
  • OpenClaw macOS
  • OpenClaw Windows
  • OpenClaw Linux
  • Hermes Agent macOS
  • Hermes Agent Windows
  • Hermes Agent Linux
  • Claude Code CLI macOS
  • Claude Code CLI Windows
  • Claude Code CLI Linux
  • Codex CLI macOS
  • Codex CLI Windows
  • Codex CLI Linux

MYAI168 API & MCP

  • MYAI168 MCP CLI
  • MYAI168 MCP Web & App