How to use the AshnaAI API in Claude Code
Create an AshnaAI API key, export ANTHROPIC_BASE_URL=https://api.ashna.ai/v1/api, paste the key, then run Claude Code. It posts Anthropic Messages to /v1/messages.
AshnaAI

What you will set up
Claude Code is an Anthropic Messages client. You will create one key, export two environment variables, pick a model id, then run a turn. Official settings: Claude Code settings. Cursor and VS Code use a different protocol: How to use the AshnaAI API in Cursor.
Step 1: Create an AshnaAI API key
Do this once. Claude Code sends the secret on every request.
- Open Account → API.
- Choose Create key and name it Claude Code.
- Copy the secret immediately. It is shown once.
- Keep it out of git, a gist, and a recorded screen.
Step 2: Export the Claude Code variables
Set both values in the same shell that will launch Claude Code.
- Export the base URL exactly as: ANTHROPIC_BASE_URL=https://api.ashna.ai/v1/api
- Export the key: ANTHROPIC_API_KEY=<the secret from Step 1>.
- If your wrapper reads ANTHROPIC_AUTH_TOKEN instead, set that name to the same secret.
- Confirm the URL includes /v1/api. A host-only value is the usual 404.
Step 3: Pick a model id
Use an alias or a catalog id. You do not change the URL.
- For Claude-style routing, set the model to sonnet, opus, or haiku.
- For a catalog model, set it to glm-5.3-flash or another listed id.
- To confirm ids, GET https://api.ashna.ai/v1/api/models with the same key.
Step 4: Run a Claude Code turn
Start the CLI from the shell that has the two variables.
- Launch Claude Code in that terminal.
- Send one prompt. The client posts to /v1/messages.
- If the turn fails with 401, the key is missing or truncated. Repeat Step 1.
- If the turn fails with 404, the base URL dropped /v1/api. Repeat Step 2.
Fields that have to match
Paste these values. A typo on the base URL is the usual failure.
| Field | Value |
|---|---|
| ANTHROPIC_BASE_URL | https://api.ashna.ai/v1/api |
| ANTHROPIC_API_KEY | Secret from Account → API |
| Messages path | /v1/messages |
| Example aliases | sonnet, opus, haiku |
| Example catalog id | glm-5.3-flash |
Try it now
HTTP notes: AshnaAI API docs and chat completions.
- Create a key in Account → API.
- Export ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY.
- Run one Claude Code turn against /v1/messages.
Frequently asked questions
- What ANTHROPIC_BASE_URL does Claude Code need?
- https://api.ashna.ai/v1/api Claude Code then posts to /v1/messages on that host.
- Does Claude Code use Chat Completions?
- No. Claude Code is a Messages client. Cursor and VS Code use Chat Completions. See How to use the AshnaAI API in Cursor.
- Which model aliases work?
- sonnet maps to claude-sonnet-5, opus to claude-opus-5, and haiku to claude-haiku-4.5. Dated Claude ids also map. glm-5.3-flash works as a catalog id.
- Where do I create the key?
- Account → API. Copy the secret once. Claude Code sends it as x-api-key or Authorization: Bearer.
- What if my tool points at https://api.ashna.ai without /v1/api?
- Prefer https://api.ashna.ai/v1/api The host also serves /v1/messages at the root if a wrapper strips the prefix.
Tags
Related
- AshnaAI for Work
- AshnaAI vs ChatGPT
- AshnaAI vs Claude
- Large Language Model (LLM)
- Foundation Model
- how to use the ashna ai api in cursor
- how to use the ashna ai api in vs code
- how to use the ashna ai api in openclaw cline and codex
- how to call any catalog model through the api
- ashna x1 task aware model routing
Try this in AshnaAI. Create a free account.
Found this article helpful? Share it with your network.