API Reference

Tài liệu tham chiếu các endpoint của nexai API.

Base URL

https://nexai.newdev.net/api/v1   # OpenAI-compatible (tất cả tools)

Endpoints

MethodEndpointMô tả
POST/v1/chat/completionsChat completion (OpenAI-compatible) — text + vision
POST/v1/responsesResponses API (cho Codex CLI và Anthropic SDK)
POST/v1/images/generationsSinh ảnh từ prompt (response trả base64)
POST/v1/audio/speechText-to-speech (response binary mp3/wav)
POST/v1/audio/transcriptionsSpeech-to-text (multipart upload, max 50MB)
GET/v1/modelsDanh sách models khả dụng

Models khả dụng

Model IDLoạiContextProvider
Chat / Text
gpt-5.5Chat1.05MAzure OpenAI 🆕
gpt-4oChat + Vision128KAzure OpenAI
gpt-4o-miniChat + Vision128KAzure OpenAI
gpt-5.4-miniChat128KAzure OpenAI
gpt-5.1-codex-miniCode128KAzure OpenAI
gpt-5.3-codexCode128KAzure OpenAI
gpt-5.4Chat128KAzure OpenAI
grok-4-fast-reasoningReasoning128KxAI
DeepSeek-R1Reasoning65KAzure/DeepSeek
Image generation
gpt-image-2ImageAzure OpenAI
gpt-image-1.5ImageAzure OpenAI
Audio
gpt-4o-mini-ttsText-to-speechAzure OpenAI
gpt-4o-transcribeSpeech-to-textAzure OpenAI

Mã lỗi

HTTP CodeÝ nghĩa
401API key không hợp lệ hoặc thiếu
402Không đủ credits
403Key bị suspended / revoked / expired
429Vượt rate limit
500Lỗi server nội bộ

Ví dụ Request

Chat completion:

curl https://nexai.newdev.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://nexai.newdev.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"
  }'

Text-to-speech (response binary, lưu thành mp3):

curl https://nexai.newdev.net/api/v1/audio/speech \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-billing-xxx" \
  -d '{
    "model": "gpt-4o-mini-tts",
    "input": "Xin chào, đây là audio được tạo bằng AI.",
    "voice": "alloy"
  }' \
  --output speech.mp3

Speech-to-text (multipart upload, max 50MB):

curl https://nexai.newdev.net/api/v1/audio/transcriptions \
  -H "Authorization: Bearer sk-billing-xxx" \
  -F file=@audio.wav \
  -F model="gpt-4o-transcribe"
Multimodal endpoints tính credits theo lượng dùng (số ảnh, character TTS, audio duration STT). Xem Lifetime spend trên trang Keys để track. TTS streaming (stream: true) chưa hỗ trợ — phase tới.
🎁 Nhận 5 triệu credits free để thử nexaiĐăng ký →