OpenRouter API

OpenRouter

OpenRouter API 中繼

OpenRouter 是 LLM gateway,一個金鑰可呼叫數百種 model (OpenAI / Anthropic / Google / Meta / Mistral 等),model 名格式為 vendor/model。

POST /futaba/api/openrouter/v1/chat/completions

Chat Completions (相容 OpenAI 格式)。

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

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

POST /futaba/api/openrouter/v1/chat/responses

Chat Responses (同 completions 結構,點數不足會直接擋下不轉發)。

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

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

POST /futaba/api/openrouter/v1/audio/speech

文字轉語音 (透過 OpenRouter 路由到 TTS 供應商)。

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

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

POST /futaba/api/openrouter/v1/audio/transcriptions

語音轉文字 (multipart upload)。

curl https://www.myai168.com/futaba/api/openrouter/v1/audio/transcriptions \
  -H "Authorization: Bearer YOUR_DEV_KEY" \
  -F file=@audio.mp3 \
  -F model=gpt-4o-transcribe
import requests

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

POST /futaba/api/openrouter/v1/video/generations

影片生成 (依 OpenRouter 支援的 video model)。

curl https://www.myai168.com/futaba/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/futaba/api/openrouter/v1/video/generations",
    headers={"Authorization": "Bearer YOUR_DEV_KEY"},
    json={"model": "vendor/some-video-model", "prompt": "A cat dancing"},
)
print(r.json())

其他常見問題頁面

  • 常見問題
  • 帳戶問題
  • 功能問題
  • 隱私權
  • OpenAI ChatGPT API
  • Anthropic Claude API
  • Google Gemini API
  • Google News API
  • API 收費
  • OpenCode
  • OpenClaw
  • Hermes Agent
  • Claude Code CLI
  • Codex CLI
  • MYAI168 MCP CLI
  • MYAI168 MCP 網頁及應用程式