Skip to content

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

APICommon EndpointDescription
ModelsGET /v1/modelsList models available to the current API key
ChatPOST /v1/chat/completionsCreate multi-turn chat completions with standard or streaming output
ResponsesPOST /responsesCreate a model response using the OpenAI Responses format
CompletionsPOST /completionsCreate a legacy text completion
EmbeddingsPOST /embeddingsConvert text into vector representations
RerankPOST /rerankRerank documents by relevance
ModerationsPOST /moderationsAnalyze input for potentially unsafe content
RealtimeRealtime WebSocket APIReal-time text and audio interaction
Audio/audio/speech, /audio/transcriptions, /audio/translationsText-to-speech, transcription, and translation
Images/images/generations, /images/editsImage generation and editing
VideosModel-specific video endpointsAI 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:

text
https://api.nexusmodels.cn/v1

Full endpoint example:

text
https://api.nexusmodels.cn/v1/chat/completions

Authentication

All model requests must include a NexusModels API key:

http
Authorization: Bearer YOUR_NEXUSMODELS_API_KEY

Example:

bash
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:

http
GET /v1/models

POST requests normally use a JSON body:

http
Content-Type: application/json

Example:

json
{
  "model": "gpt-5.4",
  "messages": [
    {
      "role": "user",
      "content": "Hello"
    }
  ]
}

File upload endpoints may use:

http
Content-Type: multipart/form-data

Response Format

Most endpoints return JSON data.

Common response fields include:

FieldTypeDescription
idstringUnique request or response identifier
objectstringObject type
modelstringModel used for the request
createdintegerResponse creation timestamp
choicesarrayGenerated results
usageobjectToken usage information

Example chat response:

json
{
  "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:

http
Content-Type: text/event-stream

Audio and image endpoints may return file URLs or binary content depending on the selected model and endpoint.

Quick Requests

List Models

bash
curl https://api.nexusmodels.cn/v1/models \
  -H "Authorization: Bearer YOUR_NEXUSMODELS_API_KEY"

Create a Chat Completion

bash
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

bash
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:

json
{
  "error": {
    "message": "Error description",
    "type": "error_type",
    "param": null,
    "code": "error_code"
  }
}

Common HTTP status codes:

HTTP StatusError TypeDescription
400invalid_request_errorInvalid request parameters or format
401authentication_errorMissing, invalid, or disabled API key
403permission_errorAccess to the requested model or endpoint is denied
404not_found_errorModel or endpoint not found
429rate_limit_errorRate, usage, or account limit exceeded
500api_errorInternal NexusModels error
502upstream_errorUpstream model provider error
503service_unavailableService 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.

View the complete error handling guide