Anthropic logoClaude Haiku 4.5 API setup guide

Call claude-haiku-4-5 through TokenRex's OpenAI-compatible chat endpoint. This guide uses a small high-volume text workflows example and explains what to verify before production.

claude-haiku-4-5

1. Prepare your account and private key

Create a TokenRex account, verify it, fund your wallet and create an API key with permission for claude-haiku-4-5. Store the key privately as TOKENREX_API_KEY on the server running your application. Never embed it in a public website, repository or browser script.

Python: install the official openai package. Node.js: add the openai package and run the example from a server-side module. Shell examples assume the private environment variable is already set.

2. Use the correct address and exact ID

OpenAI-compatible SDK base URL
https://tokenrex.ai/api/public/v1
HTTP request
POST https://tokenrex.ai/api/public/v1/chat/completions
Model ID
claude-haiku-4-5

Do not append /v1 twice. The short model ID selects the exact catalog row; naming a provider is not a substitute for choosing a model.

3. Send a small text request

The prompt below exercises high-volume text workflows. Begin with model and messages only. Add streaming after the basic request succeeds; built-in web search can be added with web_search_options (billed per search), but do not assume other provider-native settings, hosted tools such as code interpreter, or a public Responses endpoint are supported.

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["TOKENREX_API_KEY"],
    base_url="https://tokenrex.ai/api/public/v1",
)
response = client.chat.completions.create(
    model="claude-haiku-4-5",
    messages=[{"role":"user","content":"Turn this note into three concise action items: review logs, reproduce the error, verify the fix."}],
)
print(response.choices[0].message.content)
print(response.usage)

Claude's alternative Messages format

Claude can also use the Anthropic SDK and the root API address without /v1. This is a different request format, not an instruction to change the OpenAI examples above.

Configuration
import os
import anthropic

client = anthropic.Anthropic(
    api_key=os.environ["TOKENREX_API_KEY"],
    base_url="https://tokenrex.ai/api/public",
)
response = client.messages.create(
    model="claude-haiku-4-5", max_tokens=512,
    messages=[{"role": "user", "content": "Hello"}],
)
print(response.content)

4. Verify the response and recorded usage

  1. Confirm a successful response includes a usable answer; HTTP 200 alone is not a quality or compatibility test.
  2. Check the returned model identifier and usage counts, then confirm the request appears in your account's recorded usage.
  3. Try representative inputs, validate the output in your own code and check costs before increasing traffic.
  4. For tools, authorize and execute functions in your application, validate arguments and send the result back. TokenRex does not execute customer tools for you.

Troubleshooting

401 or 403
Check that the key is active, is a TokenRex key and permits this exact model. Do not print it while debugging.
402
Check wallet funding; changing the display currency does not add balance.
404 or model unavailable
Check the enabled catalog and URL. Avoid duplicate /v1 segments and wrong model spelling.
429 or a temporary service error
Respect the returned wait period and use bounded retries. A retry is a new attempt; do not silently switch models or replay consequential tools.

Model-specific checks

Compare short-request totals with longer conversations; low per-token rates alone do not determine a complete workflow cost.

Context capacity
200,000 tokens
Maximum output
64,000 tokens
Current usage price
$1.00 in / $5.00 out per 1M tokens

Limits are provider-published where a source exists, not independently tested TokenRex request limits. Exact-version benchmarks remain on the model page; scores from another variant are not copied here.

Sources and verification

TokenRex's live catalog determines availability and charges. Provider documents describe upstream behavior; they do not prove that every native feature is exposed here. These examples are not a claim of a completed live API test.

Get API keyCustom cost calculatorTool-specific integrations