Skip to contentSkip to content

Migrate from the OpenAI SDK ​

Keep the OpenAI-compatible request shape, point the SDK base URL to the AI Credits data API, and read the key from the environment. An AICredits API Key is not an official key issued by another model service. Select models from /v1/models; do not assume that a particular model is always available.

python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["AICREDITS_API_KEY"],
    base_url=os.environ["API_BASE_URL"].rstrip("/") + "/v1",
)
response = client.chat.completions.create(
    model=os.environ["MODEL"],
    messages=[{"role": "user", "content": "<YOUR_PROMPT>"}],
)

Review streaming, retry, and rate-limit behavior as part of the migration. Never attach prompts, responses, or keys to error reports.

Responses and additional models ​

The public catalog must declare the protocol you use: openai_chat_completions for Chat and openai_responses for Responses. Claude Chat / Responses compatibility is implemented. Gemini, Grok, and other models remain limited to their declared protocols; a model family does not imply support.

python
response = client.responses.create(
    model=os.environ["MODEL"],
    input="<YOUR_PROMPT>",
)

HTTP Responses rejects previous_response_id; pass conversation context explicitly. Streaming Responses uses named events and terminal states such as response.completed, not Chat's [DONE]. Send tools, tool results, and multimodal inputs in the selected protocol's format and validate your application's parameters after migration.

This page uses the OpenAI SDK with /v1 in its base URL. The AICredits official GatewayClient instead takes the root origin. Configure third-party SDK retries according to the idempotency guide.

Move to DeepSeek, Kimi, MiniMax or GLM ​

Use OpenAI Chat request shapes with published compatible models and exact catalog IDs. Do not migrate GLM calls to Responses; use Chat or Messages. Keep complete assistant messages, including reasoning_content, tool_calls and nullable content, for multi-turn tools. See Chinese model integration for parameter differences and runnable examples.