> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nodesms.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Integration Guide

> Learn about the endpoint address, authentication, and error handling to quickly connect to the AI model APIs.

This service provides OpenAI-compatible AI model APIs. Tools that already use the OpenAI SDK or support the OpenAI protocol can connect by simply replacing the **endpoint address** and **API Key**.

## Endpoint Address

| Item | Value |
| - | - |
| Base URL | `https://t.ato2.nodesms.com/v1` |
| Protocol | HTTPS |
| Data format | JSON (`application/json`); image editing, audio transcription, and audio translation use `multipart/form-data` to upload files |

## Get an API Key

1. Log in to [https://t.ato2.nodesms.com](https://t.ato2.nodesms.com).
2. Go to the token management page and create a new token.
3. Copy the generated Key (starts with `sk-`).

> [!WARNING]
>
> An API Key is equivalent to your account password. Do not expose it in frontend code, public repositories, or client applications.

## Authentication

All requests must include the API Key in the request header:

```http theme={"dark"}
Authorization: Bearer sk-xxxxxxxxxxxxxxxx
```

## Quick Test

```bash theme={"dark"}
curl https://t.ato2.nodesms.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_KEY" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [{"role": "user", "content": "Hello"}]
  }'
```

> [!NOTE]
>
> Model names in the documentation are examples only. For actual available models, call the [Models](https://docs.nodesms.com/en/aitoken/api/models.md) endpoint (`GET /v1/models`).

## Use in the SDK

```python Python theme={"dark"}
from openai import OpenAI

client = OpenAI(
    api_key="sk-xxxxxxxxxxxxxxxx",
    base_url="https://t.ato2.nodesms.com/v1",
)
```

```javascript Node.js theme={"dark"}
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "sk-xxxxxxxxxxxxxxxx",
  baseURL: "https://t.ato2.nodesms.com/v1",
});
```

In third-party clients (such as Cherry Studio, LobeChat, NextChat, etc.), select the OpenAI type and set the API address to `https://t.ato2.nodesms.com` (some clients require the full address with `/v1`).

## Error Handling

When an API error occurs, it returns an OpenAI-compatible error structure:

```json theme={"dark"}
{
  "error": {
    "message": "Error message",
    "type": "Error type",
    "param": null,
    "code": null
  }
}
```

| Field | Type | Description |
| - | - | - |
| `message` | string | Error message |
| `type` | string | Error type |
| `param` | string or null | Related parameter |
| `code` | string or null | Error code |

| HTTP Status Code | Meaning | Suggested Action |
| - | - | - |
| `400` | Request parameter error | Check request body fields and format |
| `401` | Invalid or missing API Key | Check the `Authorization` header |
| `403` | No access to this model | Confirm the available model scope of the token |
| `404` | Resource does not exist | Check whether the path or task ID is correct |
| `429` | Rate limit exceeded or insufficient quota | Reduce frequency or retry after recharging |
| `500` / `502` / `503` | Server or upstream anomaly | Retry later |

> [!TIP]
>
> Each API documentation page has an API Playground embedded on the right. Fill in your API Key to debug APIs directly online.

## API List

### Models

> **[Models](https://docs.nodesms.com/en/aitoken/api/models.md)**
>
> `GET /v1/models`

### Chat

> **[ChatCompletions Format](https://docs.nodesms.com/en/aitoken/api/chat-completions.md)**
>
> `POST /v1/chat/completions`

> **[Responses Format](https://docs.nodesms.com/en/aitoken/api/responses.md)**
>
> `POST /v1/responses`

> **[Text Completions](https://docs.nodesms.com/en/aitoken/api/completions.md)**
>
> `POST /v1/completions`

### Embeddings and Reranking

> **[Embeddings](https://docs.nodesms.com/en/aitoken/api/embeddings.md)**
>
> `POST /v1/embeddings`

> **[Rerank](https://docs.nodesms.com/en/aitoken/api/rerank.md)**
>
> `POST /v1/rerank`

### Images

> **[Image Generation](https://docs.nodesms.com/en/aitoken/api/images.md)**
>
> `POST /v1/images/generations`

> **[Image Editing](https://docs.nodesms.com/en/aitoken/api/image-edits.md)**
>
> `POST /v1/images/edits/`

### Audio

> **[Audio Speech](https://docs.nodesms.com/en/aitoken/api/audio-speech.md)**
>
> `POST /v1/audio/speech`

> **[Audio Transcription](https://docs.nodesms.com/en/aitoken/api/audio-transcriptions.md)**
>
> `POST /v1/audio/transcriptions`

> **[Audio Translation](https://docs.nodesms.com/en/aitoken/api/audio-translations.md)**
>
> `POST /v1/audio/translations`

### Video

> **[Create Video Generation Task](https://docs.nodesms.com/en/aitoken/api/videos.md)**
>
> `POST /v1/video/generations`

> **[Get Video Generation Task Status](https://docs.nodesms.com/en/aitoken/api/video-status.md)**
>
> `GET /v1/video/generations/{task_id}`

### Moderation

> **[Moderation](https://docs.nodesms.com/en/aitoken/api/moderations.md)**
>
> `POST /v1/moderations`


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.