API Reference
NexusModels provides a unified RESTful API for accessing multiple AI models.
The API is compatible with the OpenAI API format and supports text, embeddings, audio, images, video, and other model capabilities.
API availability
Supported endpoints and parameters vary by model. Use the Models API to retrieve the models available to your API key.
AI Model APIs
| API | Common Endpoint | Description |
|---|---|---|
| Models | GET /v1/models | List models available to the current API key |
| Chat | POST /v1/chat/completions | Create multi-turn chat completions with standard or streaming output |
| Responses | POST /responses | Create a model response using the OpenAI Responses format |
| Completions | POST /completions | Create a legacy text completion |
| Embeddings | POST /embeddings | Convert text into vector representations |
| Rerank | POST /rerank | Rerank documents by relevance |
| Moderations | POST /moderations | Analyze input for potentially unsafe content |
| Realtime | Realtime WebSocket API | Real-time text and audio interaction |
| Audio | /audio/speech, /audio/transcriptions, /audio/translations | Text-to-speech, transcription, and translation |
| Images | /images/generations, /images/edits | Image generation and editing |
| Videos | Model-specific video endpoints | AI video generation |
Endpoint availability depends on:
- Models available to the current API key
- Input and output types supported by the selected model
- Whether the model is currently enabled
- Upstream provider compatibility
Conventions
API Base URL
OpenAI SDKs and most API clients should use:
https://api.nexusmodels.cn/v1Full endpoint example:
https://api.nexusmodels.cn/v1/chat/completionsAuthentication
All model requests must include a NexusModels API key:
Authorization: Bearer YOUR_NEXUSMODELS_API_KEYExample:
curl https://api.nexusmodels.cn/v1/models \
-H "Authorization: Bearer YOUR_NEXUSMODELS_API_KEY"Keep your API key secure. Do not:
- Commit it to a public repository
- Include it in browser-side code
- Print it in public logs
- Share it with unauthorized users
Request Format
GET requests normally use query string parameters:
GET /v1/modelsPOST requests normally use a JSON body:
Content-Type: application/jsonExample:
{
"model": "gpt-5.4",
"messages": [
{
"role": "user",
"content": "Hello"
}
]
}File upload endpoints may use:
Content-Type: multipart/form-dataResponse Format
Most endpoints return JSON data.
Common response fields include:
| Field | Type | Description |
|---|---|---|
id | string | Unique request or response identifier |
object | string | Object type |
model | string | Model used for the request |
created | integer | Response creation timestamp |
choices | array | Generated results |
usage | object | Token usage information |
Example chat response:
{
"id": "chatcmpl-example",
"object": "chat.completion",
"created": 1780000000,
"model": "gpt-5.4",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello. How can I help you?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 15,
"total_tokens": 25
}
}Streaming endpoints return Server-Sent Events:
Content-Type: text/event-streamAudio and image endpoints may return file URLs or binary content depending on the selected model and endpoint.
Quick Requests
List Models
curl https://api.nexusmodels.cn/v1/models \
-H "Authorization: Bearer YOUR_NEXUSMODELS_API_KEY"Create a Chat Completion
curl https://api.nexusmodels.cn/v1/chat/completions \
-H "Authorization: Bearer YOUR_NEXUSMODELS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.4",
"messages": [
{
"role": "user",
"content": "Hello"
}
]
}'Create a Streaming Request
curl https://api.nexusmodels.cn/v1/chat/completions \
-H "Authorization: Bearer YOUR_NEXUSMODELS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.4",
"messages": [
{
"role": "user",
"content": "Explain artificial intelligence."
}
],
"stream": true
}'Error Handling
API errors normally use the following format:
{
"error": {
"message": "Error description",
"type": "error_type",
"param": null,
"code": "error_code"
}
}Common HTTP status codes:
| HTTP Status | Error Type | Description |
|---|---|---|
400 | invalid_request_error | Invalid request parameters or format |
401 | authentication_error | Missing, invalid, or disabled API key |
403 | permission_error | Access to the requested model or endpoint is denied |
404 | not_found_error | Model or endpoint not found |
429 | rate_limit_error | Rate, usage, or account limit exceeded |
500 | api_error | Internal NexusModels error |
502 | upstream_error | Upstream model provider error |
503 | service_unavailable | Service temporarily unavailable |
Clients should use the HTTP status code to determine whether a request should be retried. For 500, 502, and 503, use a limited exponential backoff strategy.