Examples

Integration examples

Ready-to-copy integration examples: curl, the OpenAI SDK, the Anthropic SDK, streaming, and setup for tools such as Cursor and Cline.

Before you start Replace $AAA_TOKEN_API_KEY in the samples below with your own API key, and store it in an environment variable rather than hard-coding it.

The quickest way to test: call the OpenAI-compatible chat completions endpoint directly with curl.

cURL curl https://aaa.ashp.tw/v1/chat/completions \ -H "Authorization: Bearer $AAA_TOKEN_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "claude-sonnet-4-6", "messages": [{"role": "user", "content": "Hello!"}] }'

With the official OpenAI Python SDK, just change base_url and api_key and your existing code keeps working.

OpenAI Python SDK from openai import OpenAI client = OpenAI( api_key="$AAA_TOKEN_API_KEY", base_url="https://aaa.ashp.tw/v1", ) resp = client.chat.completions.create( model="gpt-5.4", messages=[{"role": "user", "content": "Hello!"}], ) print(resp.choices[0].message.content)

With the official Anthropic SDK, point base_url at the AAA TOKEN Anthropic-compatible endpoint to use the Claude Messages API.

Anthropic Python SDK from anthropic import Anthropic client = Anthropic( api_key="$AAA_TOKEN_API_KEY", base_url="https://aaa.ashp.tw/v1/anthropic", ) msg = client.messages.create( model="claude-sonnet-4-6", max_tokens=1024, messages=[{"role": "user", "content": "Hello!"}], ) print(msg.content[0].text)

Use the official OpenAI SDK in Node.js by setting just the baseURL and your API key.

OpenAI Node.js SDK import OpenAI from "openai"; const client = new OpenAI({ apiKey: process.env.AAA_TOKEN_API_KEY, baseURL: "https://aaa.ashp.tw/v1", }); const resp = await client.chat.completions.create({ model: "gpt-5.4", messages: [{ role: "user", content: "Hello!" }], }); console.log(resp.choices[0].message.content);

Set stream=True to receive output incrementally. The Python example below reuses the client created above.

Python streaming stream = client.chat.completions.create( model="claude-sonnet-4-6", messages=[{"role": "user", "content": "Hello!"}], stream=True, ) for chunk in stream: delta = chunk.choices[0].delta.content if delta: print(delta, end="", flush=True)

Cursor, Cline and other dev tools

Cursor: in Settings → Models, enter your API key, enable Override OpenAI Base URL and paste the base URL below, then add the model names you want to use.

Cline (VS Code extension): choose OpenAI Compatible as the API provider, then enter the base URL below, your API key and a model name.

Base URL https://aaa.ashp.tw/v1

Replace $AAA_TOKEN_API_KEY with your own API key (it starts with sk-). It is sent in the Authorization header.

Get your API key Quick Start →

Sign up and get $1 free credit