Migrate from OpenAI
Replace the Base URL and API key, and update legacy SDK code to the current client API.
APIQIK is compatible with the OpenAI Chat Completions specification. Keep your messages, parameters, and response-reading logic, and change the client initialization settings.
Minimal changes
Before migration
client = OpenAI(
api_key=os.environ["OPENAI_API_KEY"]
)After migration
client = OpenAI(
api_key=os.environ["APIQIK_API_KEY"],
base_url="https://api.apiqik.com/v1",
)If APIQIK does not offer the original model under the same name, replace model with the identifier from the model catalog. Node routing does not require changes to other business logic.
Check for outdated code
Older tutorials commonly use the following patterns. Update them to the current official OpenAI SDK client API during migration.
| Area | Legacy pattern | Current pattern | Action |
|---|---|---|---|
| Python | openai.ChatCompletion.create(...) | OpenAI(...).chat.completions.create(...) | Upgrade. |
| Node.js | new Configuration() + OpenAIApi | new OpenAI({...}) | Upgrade. |
| Tool calling | functions / function_call | tools / tool_choice / tool_calls | Use the current structure. |
| Python Base URL | api_base | base_url | Use the client parameter. |
| Node.js Base URL | base_url | baseURL | Check capitalization. |
| Streaming text | message.content | delta.content | Read each chunk. |
Python migration template
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["APIQIK_API_KEY"],
base_url="https://api.apiqik.com/v1",
timeout=60.0,
max_retries=2,
)
response = client.chat.completions.create(
model="deepseek-chat",
messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)Migration checklist
- Test non-streaming, streaming, and tool-calling requests, not just a single text turn.
- Check model identifiers, context limits, supported parameters, and response-field differences.
- Ensure client timeouts and retries do not combine with platform routing retries to create excessive waits.
- Validate cost calculations against response
usageand console billing records. - Monitor error rates, P95 latency, and
finish_reasonvalues before rollout.
API compatibility does not mean every model has identical capabilities. Tool calling, multimodal input, structured output, and generation parameters depend on the selected model.