Guide

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

How to use the AshnaAI API in Claude Code

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.

  1. Open Account → API.
  2. Choose Create key and name it Claude Code.
  3. Copy the secret immediately. It is shown once.
  4. 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.

  1. Export the base URL exactly as: ANTHROPIC_BASE_URL=https://api.ashna.ai/v1/api
  2. Export the key: ANTHROPIC_API_KEY=<the secret from Step 1>.
  3. If your wrapper reads ANTHROPIC_AUTH_TOKEN instead, set that name to the same secret.
  4. 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.

  1. For Claude-style routing, set the model to sonnet, opus, or haiku.
  2. For a catalog model, set it to glm-5.3-flash or another listed id.
  3. 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.

  1. Launch Claude Code in that terminal.
  2. Send one prompt. The client posts to /v1/messages.
  3. If the turn fails with 401, the key is missing or truncated. Repeat Step 1.
  4. 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.

Claude Code fields for the AshnaAI API
FieldValue
ANTHROPIC_BASE_URLhttps://api.ashna.ai/v1/api
ANTHROPIC_API_KEYSecret from Account → API
Messages path/v1/messages
Example aliasessonnet, opus, haiku
Example catalog idglm-5.3-flash
AshnaAI HTTP API plus Claude Code settings z.ai/blog/glm-5.3-flash

Try it now

HTTP notes: AshnaAI API docs and chat completions.

  1. Create a key in Account → API.
  2. Export ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY.
  3. 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

#API#Claude Code#developers

Found this article helpful? Share it with your network.