API interfaces and compatibility
Separate protocol shape, model capabilities, and application-level validation.
Confirm the protocol before choosing a client
An API integration needs a confirmed destination, authentication method, and request format. Obtain the actual base URL and model identifier from support before selecting a corresponding client. Do not invent a domain or path, or treat another service’s configuration as the default for this site.
Compatibility has boundaries
A similar message format does not establish identical tool calling, structured output, image handling, or streaming events. Submit only confirmed parameters and validate fields your application requires. Provide an understandable error and an appropriate alternative workflow when a needed capability is not available rather than silently changing the task.
Handle responses and errors explicitly
Treat illustrative examples as a starting point for understanding an interface, not a service guarantee. Set task deadlines, distinguish partial output from complete results, and classify actual errors before retrying. Preserve redacted request evidence so support can investigate without receiving secrets or full customer content.
Server-side integration example
Install the official SDK locally (Python: pip install openai; Node.js: npm install openai). Set OPENAI_API_KEY, OPENAI_BASE_URL and OPENAI_MODEL to values confirmed by the service contact. Never paste real keys into this website or frontend code. This illustrates a common Chat Completions pattern, not a verified live endpoint.
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["OPENAI_API_KEY"],
base_url=os.environ["OPENAI_BASE_URL"],
)
result = client.chat.completions.create(
model=os.environ["OPENAI_MODEL"],
messages=[{"role": "user", "content": "Hello, AI."}],
)
print(result.choices[0].message.content)# Set these to values confirmed by your service contact.
curl "${OPENAI_BASE_URL}/chat/completions" \
-H "Authorization: Bearer ${OPENAI_API_KEY}" \
-H "Content-Type: application/json" \
-d "{\"model\":\"${OPENAI_MODEL}\",\"messages\":[{\"role\":\"user\",\"content\":\"Hello, AI.\"}]}"import OpenAI from "openai";
// Run on your server. Never expose a key in browser code.
const client = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
baseURL: process.env.OPENAI_BASE_URL,
});
const result = await client.chat.completions.create({
model: process.env.OPENAI_MODEL,
messages: [{ role: "user", content: "Hello, AI." }],
});
console.log(result.choices[0].message.content);