# Anthropic

> **You are on:** `https://api.beta.paywithlocus.com/api` | [llms.txt](https://beta.paywithlocus.com/llms.txt)
>
> Locus runs on multiple environments -- make sure every URL you call matches your expected environment.
> | Environment | Landing | API |
> |---|---|---|
> | Production | paywithlocus.com | api.paywithlocus.com |
> | Beta | beta.paywithlocus.com | api.beta.paywithlocus.com |
> | Stage | stage.paywithlocus.com | api.stage.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)

## Access Methods

| Method | Base URL | Auth |
|--------|----------|------|
| **x402 (Base)** | `https://anthropic.x402.beta.paywithlocus.com/anthropic/` | HTTP 402 auto-payment |
| **Wrapped API** | `https://api.beta.paywithlocus.com/api/wrapped/anthropic/` | `Authorization: Bearer <LOCUS_API_KEY>` |

**OpenAPI discovery:** `GET https://anthropic.x402.beta.paywithlocus.com/openapi.json`

## Endpoints

### 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)

**Payment:** x402 `upto` — the challenge amount is a maximum; the receipt contains the actual settled usage.

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `model` | string | Yes | Model ID. Public metered x402 supports 'claude-opus-4-7', 'claude-opus-4-6', 'claude-sonnet-4-6', and 'claude-haiku-4-5' (including its dated ID). |
| `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 Opus, 64k Sonnet/Haiku). |
| `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://anthropic.x402.beta.paywithlocus.com/anthropic/chat \
  -H "Content-Type: application/json" \
  -H "x-locus-request-id: <UUID from the 402 response>" \
  -d '{"model":"<string>","messages":"<array>","max_tokens":"<number>","system":"<string | array>","temperature":"<number>","top_p":"<number>","top_k":"<number>","stop_sequences":"<string[]>","thinking":"<object>","tools":"<array>","tool_choice":"<object>"}'
```

### Count Tokens

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

**Estimated cost:** $0.001

**Payment:** x402 `exact`

| 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://anthropic.x402.beta.paywithlocus.com/anthropic/count-tokens \
  -H "Content-Type: application/json" \
  -H "x-locus-request-id: <UUID from the 402 response>" \
  -d '{"model":"<string>","messages":"<array>","system":"<string | array>","tools":"<array>"}'
```
