Home / claude-sonnet-5

How do you call the claude-sonnet-5 API?

How do you call the claude-sonnet-5 API?

If you already use the official OpenAI SDK, swap base_url and api_key — every other line stays as it is.

  1. Confirm the model and group:Confirm in the dashboard that claude-sonnet-5 is available, then check the group assigned to the current account and its corresponding multiplier.
  2. Create and secure access credentials:Create access credentials according to the platform's page instructions. Inject them through environment variables or a secrets management service; do not write them into the code repository.
  3. Prepare the complete request URL:Obtain the complete API request URL from the platform documentation or console, and write it to the API_URL environment variable.
  4. Make a test request using the model ID:Pass model=claude-sonnet-5 in the request body and first use a minimal, non-sensitive input to validate the response format.
  5. Verify billing and actual behavior:Reconcile the billing result based on input, output, cache hits, and the account group. Also record latency, error codes, and rate-limiting behavior.

Complete code example

import json
import os
from urllib import request

api_url = os.environ["API_URL"]
api_key = os.environ["API_KEY"]

payload = {
    "model": "claude-sonnet-5",
    "messages": [
        {"role": "user", "content": "请用一句话说明这个请求是否已收到。"}
    ]
}

req = request.Request(
    api_url,
    data=json.dumps(payload).encode("utf-8"),
    headers={
        "Content-Type": "application/json",
        "Authorization": f"Bearer {api_key}"
    },
    method="POST"
)

with request.urlopen(req, timeout=60) as response:
    print(response.read().decode("utf-8"))

https://api.openlux.ai

More on this site

Get started

First confirm the claude-sonnet-5 group and credentials in the dashboard, then complete integration validation with a minimal request

Create an account and generate a key

Official site: OpenLux Claude Sonnet 5 API proxy

Last updated 2026-08-05 | Written and maintained by OpenLux.
Latency and pricing figures come from our own measurements. Where they differ from the vendor's site, the vendor's live page wins.