返回洞察
TutorialOctober 20, 2026约 4 分钟

How to connect frontier model APIs: one base_url line

Connecting your workload to Token Spark takes one line of configuration. The API is OpenAI-compatible, so existing SDKs, frameworks and toolchains keep working as is. This post gives the full steps with sample code.

Connecting your workload to Token Spark takes one line of configuration. The API is OpenAI-compatible, so existing SDKs, frameworks and toolchains keep working as is — no need to rewrite business code.

Three steps to connect

Step one: register and create an API key in the console. Step two: point your base_url at the platform endpoint. Step three: set the model name in the request and you are calling.

from openai import OpenAI
client = OpenAI(
    base_url="https://tokenspark.uno/v1",
    api_key="sk-xxxxxxxxxxxx",  # key created in the console
)
resp = client.chat.completions.create(
    model="<model>",  # target model, see the console list
    messages=[{"role": "user", "content": "Hello"}],
)

Once connected, the console shows per-call records: model, token usage, unit price and settled amount — all queryable. It is recommended to run non-critical tasks for a few days first, confirm latency and stability meet expectations, and only then migrate core traffic.

FAQ

Q: How much code do I need to change?

A: Usually one line: point base_url at the platform endpoint and fill in your key, then set the model name as needed.

Q: Is streaming supported?

A: Yes. The API is OpenAI-compatible and the stream parameter behaves the same; third-party clients work too.

Q: What if I hit an error?

A: Check the error-code reference in the docs center first; if it remains unresolved, reach the platform through in-site tickets with the request time and model name.

想直接开始用?

注册后即刻获得调用密钥,接入方式与主流协议完全兼容。