SDKs & frameworks

There is no AhuraSense SDK, on purpose. The API speaks the OpenAI and Anthropic protocols, so the official SDKs for those, and every framework built on them, work by changing the base URL.

OpenAI SDK#

The base URL includes /v1; the SDK appends the endpoint path.

Python

pip install openai
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.ahurasense.com/v1",
    api_key=os.environ["AHURA_API_KEY"],
)

completion = client.chat.completions.create(
    model="openai/gpt-5.4-mini",
    messages=[{"role": "user", "content": "Hello"}],
)
print(completion.choices[0].message.content)

TypeScript / Node

npm install openai
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.ahurasense.com/v1",
  apiKey: process.env.AHURA_API_KEY,
});

const completion = await client.chat.completions.create({
  model: "openai/gpt-5.4-mini",
  messages: [{ role: "user", content: "Hello" }],
});
console.log(completion.choices[0].message.content);

Anthropic SDK#

The Anthropic SDKs append /v1/messages themselves, so the base URL here is the host without /v1. They send the key as x-api-key, which the gateway accepts. The model must be a catalog id, and it does not have to be an Anthropic model: the route translates to and from the OpenAI format for any chat model.

Python

pip install anthropic
import os
from anthropic import Anthropic

client = Anthropic(
    base_url="https://api.ahurasense.com",
    api_key=os.environ["AHURA_API_KEY"],
)

message = client.messages.create(
    model="anthropic/claude-sonnet-5",
    max_tokens=512,
    messages=[{"role": "user", "content": "Hello"}],
)
print(message.content[0].text)

TypeScript / Node

npm install @anthropic-ai/sdk
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  baseURL: "https://api.ahurasense.com",
  apiKey: process.env.AHURA_API_KEY,
});

const message = await client.messages.create({
  model: "anthropic/claude-sonnet-5",
  max_tokens: 512,
  messages: [{ role: "user", content: "Hello" }],
});
console.log(message.content[0].type === "text" ? message.content[0].text : "");

LangChain#

pip install langchain-openai
import os
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="anthropic/claude-haiku-4.5",
    base_url="https://api.ahurasense.com/v1",
    api_key=os.environ["AHURA_API_KEY"],
)
print(llm.invoke("Hello").content)

Vercel AI SDK#

npm install ai @ai-sdk/openai
import { createOpenAI } from "@ai-sdk/openai";
import { generateText } from "ai";

const ahura = createOpenAI({
  baseURL: "https://api.ahurasense.com/v1",
  apiKey: process.env.AHURA_API_KEY,
});

const { text } = await generateText({
  model: ahura.chat("anthropic/claude-haiku-4.5"),
  prompt: "Hello",
});

OpenCode#

OpenCode takes custom OpenAI-compatible providers from opencode.json, in the project or under ~/.config/opencode/. The models block is the list its picker shows; name is the label, the key is the catalog id it sends. Keep the API key in an environment variable, as below, so the file can live in a repository.

opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "ahurasense": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "AhuraSense",
      "options": {
        "baseURL": "https://api.ahurasense.com/v1",
        "apiKey": "{env:AHURA_API_KEY}"
      },
      "models": {
        "anthropic/claude-sonnet-5": {
          "name": "Claude Sonnet 5",
          "limit": { "context": 1000000, "output": 128000 }
        },
        "zhipu/glm-5.3-uncensored": {
          "name": "Z.AI / GLM 5.3 Uncensored",
          "limit": { "context": 1048576, "output": 131072 }
        },
        "zhipu/glm-5.3-flash-derisked": {
          "name": "Z.AI / GLM 5.3 Flash Derisked",
          "limit": { "context": 1048576, "output": 131072 }
        },
        "qwen/qwen3.8-flash-next-uncensored": {
          "name": "Qwen / Qwen3.8 Flash Next Uncensored",
          "limit": { "context": 262144, "output": 65536 }
        }
      }
    }
  },
  "model": "ahurasense/anthropic/claude-sonnet-5"
}

Switch models inside OpenCode with /models, or start it with opencode -m ahurasense/zhipu/glm-5.3-flash-derisked. OpenCode sends reasoning_effort when you set a reasoning level, which the hosted models honour directly.

Plain HTTP#

Anything that can send JSON over HTTPS works. The request and response shapes are on the Chat completions page; streaming is server-sent events, described under Streaming.

curl
curl https://api.ahurasense.com/v1/chat/completions \
  -H "Authorization: Bearer $AHURA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"anthropic/claude-haiku-4.5","messages":[{"role":"user","content":"Hello"}]}'

Retries#

The OpenAI and Anthropic SDKs retry 429 and 5xx responses with backoff by default, and both honour Retry-After. That covers the two retryable situations the gateway produces: a rate limit, and a hosted model whose replicas are still starting. Do not retry 400, 401, 402 or 403; those need a change on your side. See Errors.

Something missing or wrong on this page? Tell us, and quote the page title.