Anthropic SDK · Python / TS
Use Messages with the API root as Base URL.
Prepare
Set the environment variables and choose a Claude model supporting Messages. Use the API root https://api.neatrouter.com; the SDK adds the request path.
Python
python -m pip install anthropicimport os
from anthropic import Anthropic
client = Anthropic(
api_key=os.environ["RELAY_API_KEY"],
base_url="https://api.neatrouter.com",
)
message = client.messages.create(
model=os.environ["RELAY_MODEL_ID"],
max_tokens=128,
messages=[{"role": "user", "content": "Hello"}],
)
print(message.content)TypeScript
npm install @anthropic-ai/sdkimport Anthropic from '@anthropic-ai/sdk';
const client = new Anthropic({
apiKey: process.env.RELAY_API_KEY,
baseURL: "https://api.neatrouter.com",
});
const message = await client.messages.create({
model: process.env.RELAY_MODEL_ID!,
max_tokens: 128,
messages: [{ role: 'user', content: 'Hello' }],
});
console.log(message.content);Scope
Run on a server and keep the key out of browser code. These are minimal text examples. Verify tools, images, caching and streaming for your chosen model.
See the official Python and TypeScript SDK documentation.
Still have a question?
Support details have not been published.