Tool setup

Use the Claude API with LangChain

LangChain's Anthropic integration accepts a custom API URL, so your chains and agents can run on Claude through apiToken.sale with a two-line change — same models, lower token price.

·

Point ChatAnthropic at the gateway

from langchain_anthropic import ChatAnthropic

llm = ChatAnthropic(
    model="claude-opus-4-8",
    anthropic_api_url="https://api.apitoken.sale",
    anthropic_api_key="sk-pool-•••",
)
print(llm.invoke("Hello").content)

That is the whole integration: the same langchain-anthropic package, the same model IDs, the same streaming and tool-calling — only the endpoint and the price change.

See also: Point the Anthropic SDK at apiToken.sale

Or configure via environment variables

export ANTHROPIC_API_URL=https://api.apitoken.sale
export ANTHROPIC_API_KEY=sk-pool-•••

With the environment set, ChatAnthropic picks up both values automatically, so shared codebases need no code change at all.

What works

  • Chains, agents and LangGraph workflows — the protocol is unchanged.
  • Streaming, tool calling and structured output through the standard integration.
  • Every supported Claude model (Opus, Sonnet, Haiku) on one key and balance.

Frequently asked questions

Does LangChain work with a custom Claude API endpoint?

Yes. ChatAnthropic accepts anthropic_api_url (or the ANTHROPIC_API_URL environment variable), so you can point it at https://api.apitoken.sale and keep everything else unchanged.

Do LangChain agents and tool calling still work?

Yes — the gateway serves the standard Anthropic Messages API, so tool calling, streaming and LangGraph agents behave exactly as with the official endpoint.

Which models can I use from LangChain?

All supported Claude models — claude-opus-4-8, claude-sonnet-5, claude-haiku-4-5 and more — on the same key and prepaid balance.

Try it before you pay: new Google/GitHub accounts include $10 of official-price Claude usage.