Bắt đầu trong 30 giây
Copy snippet, dán vào terminal hoặc IDE, chạy. Done.
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": "user", "content": "Viết hàm Python tính giai thừa."}
],
"max_tokens": 1024
}'Sẵn sàng thử?
Đăng ký miễn phí nhận ngay 5 triệu credits để test với GPT-4o, GPT-5, DeepSeek, Grok qua một endpoint duy nhất.
Snippet trên đã prefill key của bạn (nếu có). Click nút Copy, dán terminal, chạy ngay.
Tùy chọn: Cài biến môi trường để mọi tool OpenAI-compatible tự động dùng nexai
Linux / macOS — thêm vào ~/.bashrc hoặc ~/.zshrc:
export OPENAI_API_KEY="sk-billing-xxx"
export OPENAI_BASE_URL="https://nexai.newdev.net/api/v1"Windows (PowerShell):
setx OPENAI_API_KEY "sk-billing-xxx"
setx OPENAI_BASE_URL "https://nexai.newdev.net/api/v1"Streaming
Thêm "stream": true để nhận phản hồi realtime:
curl https://nexai.newdev.net/api/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-billing-xxx" \
-N \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Giải thích blockchain."}],
"stream": true,
"max_tokens": 2048
}'Dùng cờ
-N với curl để tắt buffering, thấy các chunk được gửi theo thời gian thực.Tính năng nâng cao
Function calling — model gọi function bạn định nghĩa
Định nghĩa tools mảng — model trả về tool_calls với arguments JSON khi quyết định gọi:
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": "user", "content": "Thời tiết Hà Nội?"}],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"parameters": {
"type": "object",
"properties": { "city": {"type": "string"} },
"required": ["city"]
}
}
}]
}'Vision — gpt-4o phân tích hình ảnh
Truyền hình ảnh qua image_url trong content array (URL public hoặc base64 data URL):
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": "user",
"content": [
{"type": "text", "text": "Tả ảnh này"},
{"type": "image_url", "image_url": {"url": "https://example.com/photo.jpg"}}
]
}]
}'Tạo ảnh — gpt-image-2 (mới nhất)
Endpoint /v1/images/generations với gpt-image-2 — chất lượng cao nhất, hiểu prompt tiếng Việt tốt:
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": "Cô gái Việt Nam mặc áo dài, ánh sáng tự nhiên",
"size": "1024x1024",
"n": 1
}'Tạo ảnh — gpt-image-1.5 (rẻ hơn, ổn định)
Phiên bản trước — phù hợp bulk gen, prototype, giảm ~30% chi phí so với gpt-image-2:
curl https://nexai.newdev.net/api/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-billing-xxx" \
-d '{
"model": "gpt-image-1.5",
"prompt": "A cat astronaut on the moon, realistic",
"size": "1024x1024",
"n": 1
}'