Base URL và endpoint

Với SDK và công cụ OpenAI-compatible, hãy dùng Base URL sau:

https://getrouter.ai/v1

Khi gửi yêu cầu HTTP trực tiếp, hãy nối thêm đường dẫn endpoint trong bảng dưới đây.

Các endpoint thường dùng

Khả năngPhương thứcEndpoint đầy đủ
Liệt kê mô hình theo định dạng OpenAIGEThttps://getrouter.ai/v1/models
Chat CompletionsPOSThttps://getrouter.ai/v1/chat/completions
ResponsesPOSThttps://getrouter.ai/v1/responses
Rút gọn ngữ cảnh ResponsesPOSThttps://getrouter.ai/v1/responses/compact
EmbeddingsPOSThttps://getrouter.ai/v1/embeddings
Tạo hình ảnhPOSThttps://getrouter.ai/v1/images/generations
Chỉnh sửa hình ảnhPOSThttps://getrouter.ai/v1/images/edits
Phiên âm âm thanhPOSThttps://getrouter.ai/v1/audio/transcriptions
Dịch âm thanhPOSThttps://getrouter.ai/v1/audio/translations
Chuyển văn bản thành giọng nóiPOSThttps://getrouter.ai/v1/audio/speech
Tạo tác vụ videoPOSThttps://getrouter.ai/v1/videos
Trạng thái tác vụ videoGEThttps://getrouter.ai/v1/videos/{task_id}
RerankPOSThttps://getrouter.ai/v1/rerank
Anthropic MessagesPOSThttps://getrouter.ai/v1/messages
Mô hình theo định dạng GeminiGEThttps://getrouter.ai/v1beta/models
Gemini generateContentPOSThttps://getrouter.ai/v1beta/models/{model}:generateContent

Base URL và endpoint đầy đủ

SDK thường yêu cầu Base URL rồi tự nối đường dẫn thao tác:

Base URL entered in an OpenAI SDK:
https://getrouter.ai/v1

SDK sends the request to:
https://getrouter.ai/v1/chat/completions

Một số công cụ lại yêu cầu endpoint đầy đủ. Hãy đọc nhãn của trường và hướng dẫn tích hợp trước khi tự thêm /chat/completions, /responses hoặc /messages.

Tránh lặp đường dẫn

Đường dẫn bị lặp là nguyên nhân phổ biến gây lỗi 404 Not Found.

Correct OpenAI Base URL:
https://getrouter.ai/v1

Incorrect when the tool already appends /v1:
https://getrouter.ai/v1/v1

Incorrect when the tool already appends /chat/completions:
https://getrouter.ai/v1/chat/completions/chat/completions
Tip

Nếu công cụ có các trường riêng cho API Host, API VersionEndpoint, hãy làm theo hướng dẫn tích hợp dành riêng cho công cụ đó thay vì đoán đường dẫn mà công cụ sẽ nối thêm.

Xác thực

Trừ khi hướng dẫn tích hợp quy định khác, hãy gửi:

Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

Các endpoint multipart, chẳng hạn phiên âm âm thanh và tạo video, sẽ tự đặt boundary cho Content-Type khi bạn dùng curl -F hoặc SDK.

Bước tiếp theo