1. Prepare your account
Sign in, create a dedicated API key in API Keys, and select an available model from Models & Pricing. Copy the exact model ID, including any HC suffix. A suffix marks a High-Cache route; it does not guarantee that a particular request will hit a cache.
The base URL below includes /v1 exactly once. Use the verified API address supplied for your account, not a hostname guessed from the website domain. Use HTTPS for remote connections and store API keys only on your server.
2. Make a small request
Set EASTTOKEN_BASE_URL, EASTTOKEN_API_KEY and EASTTOKEN_MODEL in your server environment. The following Python 3 example uses only the standard library and does not print your key. It calls a billable endpoint when pointed at a live service; run only after verifying the rate and balance.
import json
import os
import urllib.request
base = os.environ["EASTTOKEN_BASE_URL"].rstrip("/")
if not base.endswith("/v1"):
raise ValueError("EASTTOKEN_BASE_URL must end with /v1")
body = {
"model": os.environ["EASTTOKEN_MODEL"],
"messages": [{"role": "user", "content": "Reply with hello."}],
"max_tokens": 32,
"stream": False,
}
request = urllib.request.Request(
base + "/chat/completions",
data=json.dumps(body).encode("utf-8"),
headers={
"Authorization": "Bearer " + os.environ["EASTTOKEN_API_KEY"],
"Content-Type": "application/json",
},
method="POST",
)
with urllib.request.urlopen(request, timeout=60) as response:
result = json.load(response)
print(result["choices"][0]["message"]["content"])
print(result.get("usage", {}))3. Limits, streaming and retries
The example uses POST /v1/chat/completions with a bearer API key. Required options and supported features vary by model. For streaming, use stream=true and parse the event stream with a compatible client; this non-streaming example is not a streaming parser.
401: check the key. 403: check account/group permissions. 429: slow down and respect Retry-After when present. 400: check the model ID and request fields. For 5xx or a timeout, record the request ID and check usage before retrying: a lost response does not prove the model never ran. Do not blindly retry billable calls.
An output-token limit can affect admission and balance reservation. Keep it realistic. Increase concurrency gradually after load testing; your website server size alone does not determine model-provider capacity. Review usage and the USD price categories in the console.
4. Secure integration
Use separate keys per application, rotate leaked keys, set application-side budgets and avoid logging Authorization headers or complete prompts. Confirm data-processing terms for personal data. Before scaling up, verify small successful and failed requests and their corresponding billing.