Skip to main content

Before you start

Complete organization setup, make sure your account has inference credit, and create a key on the API Keys page. Most coding agents need a tool-capable chat model; Aider’s basic edit workflow does not require native tool calling. Image input and reasoning support depend on the model. These terminal examples use Bash or Zsh on macOS, Linux, or Windows through WSL. You need Python 3.10 or later and pip to run the SDK examples below. Install the package in the Python environment you use for your application.

Get your connection settings

Open Integrations, select a model, then choose Anthropic SDK. The screen uses your organization’s region. The examples below use the public global endpoint; replace it with your regional endpoint and replace YOUR_MODEL_ID with the full model ID shown there. Choose one of the models listed for this integration. Set your Pearl API key in the terminal where you run Anthropic SDK:

Configure Anthropic SDK

Save the Python example as pearl_example.py in this directory.
Install
Messages and token counting
In a conversation, append the assistant’s complete response.content to your messages before the next user turn. Keep thinking and tool-use blocks intact; send each tool result with its corresponding tool-use ID. See the Messages reference for streaming events and token counting. Run the saved example in the same terminal where you set your API key:
A successful run prints the input token count, then the model reply.

Set reasoning effort

The examples set the effort with extra_body={"output_config": {"effort": "high"}}, and thinking={"type": "disabled"} turns thinking off. Thinking budgets (budget_tokens) are not supported. Accepted levels are minimal, low, medium, high, xhigh, and max. The set a model actually serves is supported_efforts in its reasoning block on GET /models; any other level rounds up to the next served one, or to the highest past the top (how levels map). Omit the field for the model’s default, which is max on GLM-5.3, so set it explicitly for agents and pipelines. GLM-5.3 and GLM-5.3-Flash always reason and return 400 on the off switch. The output token limit covers the reasoning and the answer.

Stream a reply

Save this example as pearl_stream.py to print text as it arrives:

Start using Anthropic SDK

Replace the example prompt with your own request. You can review token usage and costs on the Analytics page.

Troubleshooting

  • 401: check the key and allow time for a newly created key to reach the inference gateway.
  • 404: copy the endpoint and exact model ID from Integrations. OpenAI base URLs end in /v1; the Anthropic SDK and Claude Code use the URL without that suffix.
  • 402: check your organization’s credit and billing status.
  • 429 or Anthropic 529: respect retry instructions and reduce concurrency.
  • For truncated output, check the output limit and reasoning budget. Increase limits only within the model’s maximum output length.
  • If pip is missing or reports externally-managed-environment, follow the Python package installation guide for your Python installation, then use that same interpreter to install the SDK and run the example.