API / Tương thích API
Tương thích API
Dùng endpoint tương thích OpenAI với API key.
Gateway cung cấp endpoint Chat Completions tương thích OpenAI, hỗ trợ streaming (SSE) và tool calls.
bash
curl http://localhost:8787/v1/chat/completions \
-H "Authorization: Bearer gmk_..." \
-H "Content-Type: application/json" \
-d '{"model":"gm-pro","messages":[{"role":"user","content":"Xin chào"}]}'- GET /v1/models: danh sách model kèm giá.
- POST /v1/chat/completions: messages, tools, stream, max_tokens, temperature.
- GET /v1/me, /v1/usage, /v1/limits: thông tin tài khoản.
- Idempotency-Key: tránh tính phí trùng khi thử lại.
- X-Client-Version: phiên bản client.
- x-request-id (phản hồi): mã yêu cầu để đối soát.
invalid_api_key 401, insufficient_credits 402, spend_limit_exceeded 402, model_not_found 404, rate_limited 429, no_capacity 503, upstream_error 502.
Trang này có hữu ích?