SDK SETUP

Set Python’s OpenAI base_url to Codimixa.

Keep your SDK connection in one place: the Codimixa base URL, your local API key and the model ID. The examples below use Chat Completions.

Python: configure the client.

Install the openai package in your Python environment. Set CODIMIXA_API_KEY outside the source file and replace YOUR_MODEL_ID with a Chat Completions model from the catalog.

python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["CODIMIXA_API_KEY"],
    base_url="https://api.codimixa.com/v1",
)
result = client.chat.completions.create(
    model="YOUR_MODEL_ID",
    messages=[{"role": "user", "content": "Reply with one short greeting."}],
)
print(result.choices[0].message.content)

JavaScript: use baseURL on the server.

Install the openai package in your Node.js project. Keep this code on the server, where the API key can stay in the environment.

javascript
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.CODIMIXA_API_KEY,
  baseURL: "https://api.codimixa.com/v1",
});
const result = await client.chat.completions.create({
  model: "YOUR_MODEL_ID",
  messages: [{ role: "user", content: "Reply with one short greeting." }],
});
console.log(result.choices[0].message.content);

Check the details that differ between SDKs.

Python uses base_url and api_key. JavaScript uses baseURL and apiKey. Use the base URL ending in /v1; the SDK method determines the request path.

Add features after the first request succeeds.

Check the model’s API format and supported features before adding streaming or tools. Inspect the error response if a feature call fails, and check your SDK’s retry settings so retries do not go unnoticed.

A FEW DETAILS

Before you continue

Why does changing a base URL still require a new key?

The key authenticates you to the service receiving the request. Use a Codimixa key with the Codimixa base URL.

Reference documentation

OpenAI — official Python SDKOpenAI — official JavaScript SDK