---
title: Use Anthropic SDKs with a Custom Base URL
description: "Use the official Anthropic Python and TypeScript SDKs with apiToken.sale by setting base_url to api.apitoken.sale. Same SDK, same code, lower cost per token."
url: https://apitoken.sale/docs/learn/anthropic-sdk-base-url
language: en
---

# Point the Anthropic SDK at apiToken.sale

The official Anthropic SDKs let you override the base URL, so switching to apiToken.sale is a one-line change — your model IDs and message code stay exactly the same.

## Python

```
from anthropic import Anthropic

client = Anthropic(
    base_url="https://api.apitoken.sale",
    api_key="sk-pool-•••",
)
msg = client.messages.create(
    model="claude-opus-4-8",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}],
)
```

## TypeScript

```
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  baseURL: "https://api.apitoken.sale",
  apiKey: "sk-pool-•••",
});
const msg = await client.messages.create({
  model: "claude-opus-4-8",
  max_tokens: 1024,
  messages: [{ role: "user", content: "Hello" }],
});
```

## Verify the switch worked

After changing the base URL, make one request and confirm you get a normal Anthropic response. Streaming, tool use and system prompts all behave exactly as with api.anthropic.com — only the billing endpoint changed.

- A 401 means the key or base URL is wrong — re-check both.
- Keep the same model IDs; no code around messages needs to change.
- Read usage per request in the dashboard to confirm spend and your discount.

## Frequently asked questions

### Can I keep using the official Anthropic SDK?

Yes. Set base_url (Python) or baseURL (TypeScript) to apiToken.sale and everything else stays the same.

### Do model IDs change?

No. Use the same model IDs such as claude-opus-4-8 and claude-sonnet-5.

---
Get a key: https://apitoken.sale/register
More guides: https://apitoken.sale/docs/learn
