# HaryAI API: chat models

HaryAI serves DeepSeek models through OpenAI- and Anthropic-compatible APIs.
One API key, one balance. Get the key from your account page:
https://haryai.com/en/dashboard

## Base URLs

| Format | Base URL |
|---|---|
| OpenAI (Chat Completions, Responses) | `https://api.haryai.com/v1` |
| Anthropic (Messages) | `https://api.haryai.com` (the client appends `/v1/messages`) |

## Authentication

- `Authorization: Bearer <HARYAI_KEY>` on every endpoint.
- `/v1/messages` also accepts `x-api-key: <HARYAI_KEY>`.

## Endpoints

| Method and path | Use |
|---|---|
| `POST /v1/chat/completions` | OpenAI Chat Completions |
| `POST /v1/responses` | OpenAI Responses (what Codex uses) |
| `POST /v1/messages` | Anthropic Messages (what Claude Code uses) |
| `GET /v1/models` | Models your key can use |
| `POST /v1/images/generations` | Images, OpenAI format (Seedream 5.5): https://haryai.com/docs/image.md |
| `POST /v1beta/models/{model}:generateContent` | Images, Gemini format (Nano Banana 2): https://haryai.com/docs/image.md |
| `POST /api/v3/contents/generations/tasks`, `POST /v1/videos` | Video (Seedance 2.5): https://haryai.com/docs/video.md |

Other paths return 404.

## Models

| Model name | Model | Context | Max output |
|---|---|---|---|
| `deepseek-flash` | DeepSeek V4.1 Flash | 1M | 384K |
| `deepseek-v4-pro` | DeepSeek V4 Pro | 1M | 384K |

`deepseek-v4-flash` is retired. The name still works and is served by
DeepSeek V4.1 Flash.

## Example

```sh
curl https://api.haryai.com/v1/chat/completions \
  -H "Authorization: Bearer $HARYAI_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"deepseek-flash","messages":[{"role":"user","content":"Hello"}]}'
```

## Codex and Claude Code

- Codex: base URL `https://api.haryai.com/v1`, wire API `responses`, model
  `deepseek-flash`.
- Claude Code: `ANTHROPIC_BASE_URL=https://api.haryai.com`,
  `ANTHROPIC_AUTH_TOKEN=<HARYAI_KEY>`, model `deepseek-flash`.
- The config to paste, CC Switch import and how to undo it:
  https://haryai.com/zh/help/setup

## Errors

Shape: `{"error":{"message":"…","type":"new_api_error","code":"<code>"}}`.
Errors from DeepSeek on `/v1/messages` use the Anthropic shape
(`{"type":"error","error":{…}}`). Errors raised before the request reaches
the model (key, model, balance) always use the first shape.

| Status | Code | Meaning | What to do |
|---|---|---|---|
| 401 | (empty) | Missing or invalid key (`Invalid token`) | Check the key on the account page |
| 400 | `model_not_found` | The model name is not available to your account | Use a model name from the table above |
| 503 | `model_not_found` | The model is available to you but can't be served right now | Retry later |
| 403 | `insufficient_user_quota` | Balance too low for this request | Top up, or buy a plan |
| 429 | varies | The model provider is busy | Wait a few seconds and retry |
| 5xx | varies | The model provider failed | Retry |

The message ends with `(request id: …)`. Send that id to
support@haryai.com when asking about a failed request.
