API Reference
Tài liệu tham chiếu các endpoint của nexai API.
Base URL
https://getnexai.net/api/v1 # OpenAI-compatible (tất cả tools)Endpoints
| Method | Endpoint | Mô tả |
|---|---|---|
| POST | /v1/chat/completions | Chat completion (OpenAI-compatible) — text + vision |
| POST | /v1/responses | Responses API (cho Codex CLI và Anthropic SDK) |
| POST | /v1/images/generations | Sinh ảnh từ prompt (response trả base64) |
| POST | /v1/audio/speech | Text-to-speech (response binary mp3/wav) |
| POST | /v1/audio/transcriptions | Speech-to-text (multipart upload, max 50MB) |
| GET | /v1/models | Danh sách models khả dụng |
Models khả dụng
| Model ID | Loại | Context | Provider |
|---|---|---|---|
| Chat / Text | |||
| gpt-5.5 | Chat | 1.05M | Azure OpenAI 🆕 |
| gpt-4o | Chat + Vision | 128K | Azure OpenAI |
| gpt-4o-mini | Chat + Vision | 128K | Azure OpenAI |
| gpt-5.4-mini | Chat | 128K | Azure OpenAI |
| gpt-5.1-codex-mini | Code | 128K | Azure OpenAI |
| gpt-5.3-codex | Code | 128K | Azure OpenAI |
| gpt-5.4 | Chat | 128K | Azure OpenAI |
| grok-4-fast-reasoning | Reasoning | 128K | xAI |
| DeepSeek-R1 | Reasoning | 65K | Azure/DeepSeek |
| Image generation | |||
| gpt-image-2 | Image | — | Azure OpenAI |
| gpt-image-1.5 | Image | — | Azure OpenAI |
Mã lỗi
| HTTP Code | Ý nghĩa |
|---|---|
| 401 | API key không hợp lệ hoặc thiếu |
| 402 | Không đủ credits |
| 403 | Key bị suspended / revoked / expired |
| 429 | Vượt rate limit |
| 500 | Lỗi server nội bộ |
Ví dụ Request
Chat completion:
curl https://getnexai.net/api/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-billing-xxx" \
-d '{
"model": "gpt-4o",
"messages": [
{"role": "system", "content": "Bạn là trợ lý AI hữu ích."},
{"role": "user", "content": "Giải thích REST API là gì?"}
],
"max_tokens": 1024,
"temperature": 0.7,
"stream": false
}'Image generation (response trả data[0].b64_json):
curl https://getnexai.net/api/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-billing-xxx" \
-d '{
"model": "gpt-image-2",
"prompt": "A cute baby sea otter, watercolor style",
"n": 1,
"size": "1024x1024"
}'Multimodal endpoints tính credits theo lượng dùng (số ảnh). Xem Lifetime spend trên trang Keys để track.