OpenRouter 是 LLM gateway,一個金鑰可呼叫數百種 model (OpenAI / Anthropic / Google / Meta / Mistral 等),model 名格式為 vendor/model。
POST /futaba/api/openrouter/v1/chat/completionsChat 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/responsesChat 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())