PIKTOKEN / DEVELOPER DOCUMENTATION
One familiar API.
A clearer path to your models.
Use OpenAI Chat Completions with a PikToken key. Keep keys on your server; never include them in browser code or public repositories.
1. Account and API key
Create an account, open API keys in your console and generate a key. Copy it immediately: only its hash is saved. Set a lifetime budget, expiry date and requests per minute limit.
2. Fund your account
Read the billing page instructions before paying. Submit the payment reference for manual review. Only confirmed receipts become available balance. If no instructions appear, funding has not opened yet.
3. Connect your SDK
from openai import OpenAI
import os
client = OpenAI(
api_key=os.environ["PIKTOKEN_API_KEY"],
base_url="https://YOUR-PIKTOKEN-HOST/api/v1",
)
response = client.chat.completions.create(
model="glm-4.6v",
messages=[{"role": "user", "content": "Hello!"}],
max_tokens=256,
extra_body={"thinking": {"type": "disabled"}},
)
print(response.choices[0].message.content)Streaming
Set stream: true. PikToken requests usage from the provider, forwards SSE data, settles the bill and sends data: [DONE]. Consume the final event. Disconnecting early can retain the maximum reservation pending review.
stream = client.chat.completions.create(
model="glm-4.6v",
messages=[{"role": "user", "content": "Explain token routing."}],
max_tokens=256,
stream=True,
)
for chunk in stream:
if chunk.choices:
print(chunk.choices[0].delta.content or "", end="")Vision and function calling
Messages can contain text and image parts in the provider format. Function tools are supported. Provider built-in paid tools, multiple choices and undocumented parameters are rejected to keep charges predictable.
{
"model": "glm-4.6v",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this image."
},
{
"type": "image_url",
"image_url": {
"url": "https://example.com/image.jpg"
}
}
]
}
],
"max_tokens": 256
}Endpoints and limits
POST /api/v1/chat/completions forwards metered completions. GET /api/v1/models lists active aliases. Equivalent /v1 paths are supported. Other OpenAI endpoints are not implemented.
Request limit: 1 MiB. Response limit: 8 MiB. Upstream deadline: 120 seconds. Output defaults to 1,024 tokens within the configured model limit. Key RPM and budget limits apply across concurrent calls.
Billing and reservations
Before contacting the provider, PikToken reserves the configured maximum model context cost plus requested output cost. Concurrent requests cannot spend the same balance. Successful calls bill provider-reported input, cached input and output, rounded up to a millionth of a dollar, then release the remainder. Retail rates appear in the model catalog.
Upstream HTTP failures release the full reservation. Missing or invalid usage, broken streams and ambiguous completions retain the maximum reservation for review. Your request ID and settlement state appear in Usage. Contact Support for a documented refund after the provider charge is checked.
Error handling
401: invalid or expired key. 403: suspended account or forbidden action. 402: insufficient reservation balance. 404: unavailable model. 429: rate or budget limit. 502: upstream failure. 503: configuration or storage unavailable.
Use the x-request-id header for tracing. A failure after generation began may have incurred a charge; do not blindly retry. Prompts and responses are not retained in usage logs.
Upstream configuration
Administrators save provider credentials in Secure upstreams. AES-GCM encryption protects stored keys; the original value is never returned. Replacement disables the provider until a fresh test passes. Then enable the provider and set public aliases and customer rates. The first preset uses Z.AI model glm-4.6v.
Use API credentials with commercial authorization. Subscription or Coding Plan keys are not assumed to authorize resale. Provider policies govern retention, training and processing regions.
Recovery and support
Email verification and password recovery become available after the administrator configures a verified sender. Changing your password in Account revokes other sessions. Support requests should include a request ID and exclude secret keys.
Published platform features
Features below have passed release verification. This list does not describe pricing, plans or service levels.
- Hosting and account sign-in — The platform runs on its own hosting with account registration and sign-in. (Document version 1)
- Upstream supplier records — Administrators keep records of upstream suppliers and their connections. (Document version 1)
- Procurement and entitlement records — Administrators record upstream purchases and the usage rights they include. (Document version 1)
- Model inventory — Administrators maintain an inventory of upstream models and their recorded capabilities. (Document version 1)