curl#
Прямые HTTP-запросы — для отладки или скриптов.
Список моделей#
bash
curl https://api.ml-router.su/v1/models \
-H "Authorization: Bearer orb_live_…" \
| jq '.data[] | .id'
Chat completion#
bash
curl https://api.ml-router.su/v1/chat/completions \
-H "Authorization: Bearer orb_live_…" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-4o-mini",
"messages": [{"role": "user", "content": "Hello"}]
}'
С извлечением ответа и стоимости:
bash
curl -s https://api.ml-router.su/v1/chat/completions \
-H "Authorization: Bearer orb_live_…" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-4o-mini",
"messages": [{"role": "user", "content": "Hello"}]
}' | jq -r '
"Reply: \(.choices[0].message.content)",
"Cost: $\(.usage.cost)"
'
Streaming#
bash
curl -N https://api.ml-router.su/v1/chat/completions \
-H "Authorization: Bearer orb_live_…" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-4o-mini",
"messages": [{"role": "user", "content": "Расскажи историю"}],
"stream": true
}'
-N (--no-buffer) — обязателен, иначе curl буферизует и токены не пойдут
в реальном времени.
С env-переменной#
```bash export ORB_API_KEY="orb_live_..."
curl https://api.ml-router.su/v1/chat/completions \ -H "Authorization: Bearer $ORB_API_KEY" \ -H "Content-Type: application/json" \ -d '{ ... }' ```
Bash-функция#
Положи в ~/.bashrc / ~/.zshrc:
bash
orb() {
local prompt="$*"
curl -s https://api.ml-router.su/v1/chat/completions \
-H "Authorization: Bearer $ORB_API_KEY" \
-H "Content-Type: application/json" \
-d "$(jq -n --arg p "$prompt" '{
model: "openai/gpt-4o-mini",
messages: [{role:"user", content:$p}]
}')" | jq -r '.choices[0].message.content'
}
bash
$ orb "что такое сегментация в Linux"
…
Smoke-test ключа#
One-liner для проверки нового ключа:
bash
curl -sS https://api.ml-router.su/v1/chat/completions \
-H "Authorization: Bearer $ORB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-4o-mini",
"messages": [{"role":"user","content":"ping"}]
}' | jq '.choices[0].message.content, .usage.cost'
С sandbox-ключом (orb_test_…) ответ будет pong и cost: 0 — удобно
встраивать в CI как health-check интеграции.