Connect your tools
OpenAI and Anthropic SDKs
Call us from your own code with the official SDKs — change only the address and key.
About 8 minFor:Developers calling models from their own code
Before you start
- Python 3 or Node.js
- A key stored in an environment variable, not in the code
Step 1 · STEP 0x01
Install and set the key
$ pip install openai anthropic$ npm install openai @anthropic-ai/sdk$ export API_KEY=<YOUR_API_KEY>
Step 2 · STEP 0x02
OpenAI SDK: Python
import os
from openai import OpenAI
client = OpenAI(base_url="https://api.suanlimao.shop/v1", api_key=os.environ["API_KEY"])
resp = client.chat.completions.create(
model="<MODEL_NAME>",
messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)$ python demo.pyHello! How can I help you today?
https://api.suanlimao.shop/v1 as the API address (with /v1). If the tool says 404, check whether /v1 is missing or doubled, then read the FAQ below.Step 3 · STEP 0x03
OpenAI SDK: Node.js (streaming)
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.suanlimao.shop/v1", apiKey: process.env.API_KEY });
const stream = await client.chat.completions.create({
model: "<MODEL_NAME>",
messages: [{ role: "user", content: "Hello" }],
stream: true,
});
for await (const chunk of stream) process.stdout.write(chunk.choices[0]?.delta?.content ?? "");$ node demo.mjsHello! How can I help you today?
In streaming mode the last chunk carries usage, followed by data: [DONE]. During long pauses the server sends : ping comment lines to keep the connection open; SDKs ignore them.
Step 4 · STEP 0x04
Anthropic SDK (Claude models)
import os
import anthropic
client = anthropic.Anthropic(base_url="https://api.suanlimao.shop", api_key=os.environ["API_KEY"])
msg = client.messages.create(
model="<MODEL_NAME>",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}],
)
print(msg.content[0].text)$ python claude_demo.pyHello! …
base_url is the root https://api.suanlimao.shop without /v1 — the SDK adds the path. Only the OpenAI SDK takes /v1.Step 5 · STEP 0x05
No code changes: use environment variables
$ export OPENAI_BASE_URL=https://api.suanlimao.shop/v1$ export OPENAI_API_KEY=<YOUR_API_KEY>$ python your_existing_script.py
OPENAI_BASE_URL and OPENAI_API_KEY, so existing scripts work without code changes — just use a model name from the plaza.✓ How to tell it worked
- The script prints an answer and the Usage page shows the request.
FAQ
404?
OpenAI SDK address takes /v1, the Anthropic SDK does not; then check the model name.
429?
You hit a rate limit or a key budget. Wait for Retry-After and retry with exponential backoff.
Timeouts?
Long outputs and reasoning models take longer — raise the SDK timeout and use streaming to see output sooner.
Related tutorials
Still stuck?
Read the troubleshooting tutorials first. If that does not help, open a ticket with the request_id, time, model and the exact error (never paste your key).