# Anthropic — Wrapped API

> **You are on:** `https://api.paywithlocus.com/api` | [llms.txt](https://paywithlocus.com/llms.txt) | [docs](https://docs.paywithlocus.com)
>
> Locus runs on multiple environments -- make sure every URL you call matches your expected environment.
> | Environment | Landing | API | Docs |
> |---|---|---|---|
> | Production | paywithlocus.com | api.paywithlocus.com | docs.paywithlocus.com |
> | Beta | beta.paywithlocus.com | api.beta.paywithlocus.com | docs.paywithlocus.com |
> | Stage | stage.paywithlocus.com | api.stage.paywithlocus.com | docs.paywithlocus.com |
>
> If the API URL above doesn't match your expected environment, re-fetch this file from the correct domain.

> Claude AI models — chat completions, vision, document processing, extended thinking, and tool use.

**Category:** AI / LLM | **Website:** [anthropic.com](https://anthropic.com) | **Docs:** [docs.anthropic.com](https://docs.anthropic.com)

Pay-per-use API proxy. Each call is automatically billed to your wallet in USDC.

## Access

**Base URL:** `https://api.paywithlocus.com/api/wrapped/anthropic/`
**Auth:** `Authorization: Bearer <LOCUS_API_KEY>`

> Also available via public x402 on Base (no account needed): [x402/anthropic.md](https://paywithlocus.com/x402/anthropic.md)

## Endpoints

### List Models

List the Claude models available to the configured upstream account, newest first.

**Estimated cost:** Free

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `limit` | number | No | Maximum number of models to return (1–1000) |
| `after_id` | string | No | Return models after this pagination cursor |
| `before_id` | string | No | Return models before this pagination cursor |

```bash
curl -X POST https://api.paywithlocus.com/api/wrapped/anthropic/models \
  -H "Authorization: Bearer YOUR_LOCUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```

### Messages

Generate text with Claude models. Supports text, vision (images via base64 or URL), document processing (PDF), extended thinking, tool use, and structured output.

**Estimated cost:** Model-dependent (~$0.001–$0.20)

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `model` | string | Yes | Model ID. Current public metered x402 models include 'claude-fable-5', 'claude-opus-5', 'claude-sonnet-5', 'claude-opus-4-8', and earlier reviewed Claude 4 models. |
| `messages` | array | Yes | Conversation messages. Each: { role: "user"\|"assistant", content: "text" } or multimodal: { role: "user", content: [{ type: "text", text: "..." }, { type: "image", source: { type: "base64", media_type: "image/png", data: "..." } }] } |
| `max_tokens` | number | Yes | Maximum output tokens. x402 enforces the selected model limit (128k for current Claude 5 and recent Opus/Sonnet models; 64k for Haiku 4.5). |
| `system` | string \| array | No | System prompt. Can be a string or array of content blocks: [{ type: "text", text: "..." }] |
| `temperature` | number | No | Sampling temperature (0.0–1.0, default 1.0) |
| `top_p` | number | No | Nucleus sampling threshold |
| `top_k` | number | No | Top-K sampling (only sample from top K tokens) |
| `stop_sequences` | string[] | No | Custom stop sequences to end generation |
| `thinking` | object | No | Enable extended thinking. { type: "enabled", budget_tokens: 10000 }. Thinking tokens are billed at the output token rate. |
| `tools` | array | No | Tool definitions for function calling. Each: { name, description, input_schema: { type: "object", properties: {...} } } |
| `tool_choice` | object | No | Tool use control: { type: "auto" } (default), { type: "any" }, { type: "tool", name: "tool_name" }, or { type: "none" } |

```bash
curl -X POST https://api.paywithlocus.com/api/wrapped/anthropic/chat \
  -H "Authorization: Bearer YOUR_LOCUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"claude-haiku-4-5","messages":[{"role":"user","content":"Reply with exactly the word PONG."}],"max_tokens":32}'
```

### Count Tokens

Count tokens for a message payload before sending. Useful for cost estimation and staying within context limits.

**Estimated cost:** $0.001

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `model` | string | Yes | Model ID to count tokens for |
| `messages` | array | Yes | Messages array (same format as Messages endpoint) |
| `system` | string \| array | No | System prompt to include in token count |
| `tools` | array | No | Tool definitions to include in token count |

```bash
curl -X POST https://api.paywithlocus.com/api/wrapped/anthropic/count-tokens \
  -H "Authorization: Bearer YOUR_LOCUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"claude-haiku-4-5","messages":[{"role":"user","content":"Hello from the Locus API audit"}]}'
```
