> For the complete documentation index, see [llms.txt](https://docs.dos.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.dos.ai/api-reference/openapi-spec.md).

# OpenAPI Specification

The complete DOS AI API is documented using the OpenAPI Specification (OAS 3.1.0). You can access the machine-readable specification in either YAML or JSON format:

* **YAML:** [`https://api.dos.ai/openapi.yaml`](https://api.dos.ai/openapi.yaml)
* **JSON:** [`https://api.dos.ai/openapi.json`](https://api.dos.ai/openapi.json)

These specifications can be used with tools like **Swagger UI**, **Postman**, **Insomnia**, **Scalar**, or any OpenAPI-compatible SDK code generator to explore the API, run tests, or generate strongly typed client libraries.

***

## What is in the Specification?

The specification covers all core endpoints and capabilities of DOS AI:

| Tag                    | Key Endpoints                                                | Description                                                                                          |
| ---------------------- | ------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------- |
| **Chat**               | `POST /v1/chat/completions`                                  | Chat completions, streaming SSE, tool calling, JSON schema mode, and per-request `cost` calculation. |
| **API Keys**           | `GET /v1/key`, `GET /v1/auth/key`                            | API key metadata, usage, and balance checking (compatible with OpenRouter format).                   |
| **Billing & Balance**  | `GET /v1/user/balance`, `GET /v1/credits`                    | Balance and credit queries (compatible with CC Switch, DeepSeek, and NewAPI formats).                |
| **Models**             | `GET /v1/models`, `GET /v1/models/{model_id}`                | Dynamic model catalog with context windows and per-token `pricing`.                                  |
| **Embeddings**         | `POST /v1/embeddings`                                        | Text embeddings generation.                                                                          |
| **Anthropic Messages** | `POST /v1/messages`, `POST /v1/messages/count_tokens`        | Anthropic-compatible Messages API and zero-cost token counting.                                      |
| **Batches**            | `POST /v1/files`, `POST /v1/batches`, `GET /v1/batches/{id}` | Asynchronous batch processing at 50% discount.                                                       |
| **Media Generation**   | `POST /v1/{images,videos,audio}/generations`                 | Multimodal generation for images, videos, and music.                                                 |

***

## Using with Postman / Insomnia

You can import the complete DOS AI API collection into Postman or Insomnia with a single click:

1. Open **Postman** (or Insomnia).
2. Click **Import** in the top left corner.
3. Paste the URL:

   ```
   https://api.dos.ai/openapi.json
   ```
4. Click **Import**. Postman will generate an organized collection with all endpoints, headers, and request body templates.
5. Set your collection variable `apiKey` to your DOS AI API key (`dos_sk_...`) and start sending requests immediately.

***

## Using with Swagger UI / Scalar

To run an interactive Swagger UI locally with the DOS AI specification:

```bash
# Using Docker
docker run -p 8080:8080 -e SWAGGER_JSON_URL=https://api.dos.ai/openapi.json swaggerapi/swagger-ui
```

Visit `http://localhost:8080` in your browser to inspect and interact with the endpoints.

***

## Generating Client SDKs

You can use the official [OpenAPI Generator](https://openapi-generator.tech/) or modern tools like [Fern](https://buildwithfern.com/) or [Stainless](https://www.stainlessapi.com/) to automatically generate type-safe client libraries for your tech stack:

### Python Client

```bash
npx @openapitools/openapi-generator-cli generate \
  -i https://api.dos.ai/openapi.json \
  -g python \
  -o ./dos-ai-python-sdk \
  --additional-properties=packageName=dosai
```

### TypeScript / Node.js Client

```bash
npx @openapitools/openapi-generator-cli generate \
  -i https://api.dos.ai/openapi.json \
  -g typescript-axios \
  -o ./dos-ai-ts-sdk
```

### Go Client

```bash
npx @openapitools/openapi-generator-cli generate \
  -i https://api.dos.ai/openapi.json \
  -g go \
  -o ./dos-ai-go-sdk \
  --additional-properties=packageName=dosai
```

***

## Authentication in OpenAPI

All endpoints (except public routes such as `GET /v1/models`) require Bearer token authentication defined by the `BearerAuth` security scheme:

```http
Authorization: Bearer dos_sk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.dos.ai/api-reference/openapi-spec.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
