Guide

How to use the AshnaAI API in Claude Code

Install Claude Code CLI on macOS, Linux, or Windows, create an AshnaAI API key, point ANTHROPIC_BASE_URL at https://api.ashna.ai/v1/api, then run your first Messages turn.

AshnaAI

How to use the AshnaAI API in Claude Code

What you will set up

This guide walks through installing Claude Code CLI on your machine, creating one AshnaAI API key, pointing Claude Code at the AshnaAI Anthropic-compatible endpoint, and running your first turn. Official install docs: Claude Code quickstart. Cursor uses a different protocol — see How to use the AshnaAI API in Cursor.

Step 1: Install Claude Code CLI

Claude Code is Anthropic’s terminal agent. Install it once per machine, then route requests to AshnaAI with environment variables. The commands below match the official quickstart.

macOS, Linux, and WSL
▸ curl -fsSL https://claude.ai/install.sh | bash
Windows PowerShell
irm https://claude.ai/install.ps1 | iex
Windows CMD
▸ curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd
Verify the install
▸ claude --version
  1. Open a terminal in the project folder you want to work in.
  2. Run the install command for your operating system.
  3. Confirm the install with claude --version.
  4. Set ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY in Step 3 before your first turn.

Step 2: Create an AshnaAI API key

Do this once. Claude Code sends the secret on every request to AshnaAI.

  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 3: Point Claude Code at AshnaAI

Export both variables in the same shell that will launch Claude Code. Settings reference: Claude Code settings.

macOS, Linux, and WSL (bash or zsh)
▸ export ANTHROPIC_BASE_URL="https://api.ashna.ai/v1/api"
▸ export ANTHROPIC_API_KEY="paste-your-key-here"
Windows PowerShell (current session)
$env:ANTHROPIC_BASE_URL="https://api.ashna.ai/v1/api"//api.ashna.ai/v1/api"
$env:ANTHROPIC_API_KEY="paste-your-key-here"
Windows CMD (current session)
▸ set ANTHROPIC_BASE_URL=https://api.ashna.ai/v1/api
▸ set ANTHROPIC_API_KEY=paste-your-key-here
  1. Confirm the base URL includes /v1/api. A host-only value is the usual 404.
  2. If your wrapper reads ANTHROPIC_AUTH_TOKEN instead, set that name to the same secret.
  3. Add the export lines to ~/.zshrc, ~/.bashrc, or your shell profile to persist them.

Step 4: Pick a model id

Use an alias or a catalog id. You do not change the URL.

  1. Set the model to sonnet, opus, haiku, or a catalog id when Claude Code asks.
  2. For Claude-style routing, choose sonnet, opus, or haiku.
  3. For a catalog model, type glm-5.3-flash or another listed id.
  4. To list ids from the API, run: curl -H "Authorization: Bearer YOUR_KEY" https://api.ashna.ai/v1/api/models

Step 5: Run your first Claude Code turn

Start the CLI from the shell that has the two environment variables.

Start Claude Code in your repo
▸ cd /path/to/your/project
▸ claude
  1. Send one prompt such as explain the folder structure.
  2. Claude Code posts to /v1/messages on api.ashna.ai.
  3. If the turn fails with 401, the key is missing or truncated. Repeat Step 2.
  4. If the turn fails with 404, the base URL dropped /v1/api. Repeat Step 3.

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
Install (macOS/Linux)curl -fsSL https://claude.ai/install.sh | bash
Install (Windows)irm https://claude.ai/install.ps1 | iex
ANTHROPIC_BASE_URLhttps://api.ashna.ai/v1/api
ANTHROPIC_API_KEYSecret from Account → API
Messages path/v1/messages
Example aliasessonnet, opus, haiku
AshnaAI HTTP API plus Claude Code settings www.ashna.ai/api-docs

Try it now

HTTP reference: AshnaAI API docs and chat completions for other clients.

  1. Install Claude Code with the command for your OS.
  2. Create a key in Account → API.
  3. Export ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY, then run one turn.

Frequently asked questions

How do I install Claude Code on macOS or Linux?
Run curl -fsSL https://claude.ai/install.sh | bash from a terminal, then verify with claude --version. Full steps: https://code.claude.com/docs/en/quickstart
How do I install Claude Code on Windows?
In PowerShell run irm https://claude.ai/install.ps1 | iex, or in CMD use the install.cmd one-liner from the Claude Code quickstart. Then run claude --version.
What ANTHROPIC_BASE_URL does Claude Code need for AshnaAI?
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 an Anthropic Messages client. Cursor and VS Code use Chat Completions instead.
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 and catalog ids such as glm-5.3-flash also work.

Tags

#API#Claude Code#developers

Found this article helpful? Share it with your network.