Build
Connect the tools you already use.
CostIQ works with clients that accept an OpenAI-compatible base URL, bearer key, and model alias. Keep every credential scoped to one person, service, and environment.
Shared configuration
Set the same three environment variables regardless of client.
Shell
export COSTIQ_BASE_URL=https://inference.costiq.xyz/v1
export COSTIQ_MODEL=general-fast
printf 'CostIQ API key: ' >&2
read -r -s COSTIQ_API_KEY && printf '\n' >&2
export COSTIQ_API_KEYPY
Python
Official OpenAI Python client with a custom base URL.
Install
env -u COSTIQ_API_KEY python3 -m pip install openaiclient.py
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["COSTIQ_API_KEY"],
base_url=os.environ.get(
"COSTIQ_BASE_URL",
"https://inference.costiq.xyz/v1",
).rstrip("/"),
max_retries=0,
timeout=60.0,
)
response = client.chat.completions.create(
model=os.environ.get("COSTIQ_MODEL", "general-fast"),
messages=[{"role": "user", "content": "Reply with gateway-ok"}],
)
print(response.choices[0].message.content)TS
TypeScript
Official OpenAI JavaScript client with retries disabled.
Install
env -u COSTIQ_API_KEY npm install openaiclient.ts
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.COSTIQ_API_KEY,
baseURL:
process.env.COSTIQ_BASE_URL ??
"https://inference.costiq.xyz/v1",
maxRetries: 0,
timeout: 60_000,
});
const response = await client.chat.completions.create({
model: process.env.COSTIQ_MODEL ?? "general-fast",
messages: [{ role: "user", content: "Reply with gateway-ok" }],
});
console.log(response.choices[0]?.message.content);OC
OpenCode
Register CostIQ as an OpenAI-compatible provider.
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"costiq": {
"npm": "@ai-sdk/openai-compatible",
"name": "CostIQ",
"options": {
"baseURL": "{env:COSTIQ_BASE_URL}",
"apiKey": "{env:COSTIQ_API_KEY}"
},
"models": {
"general-fast": { "name": "General Fast" }
}
}
},
"model": "costiq/general-fast"
}Start OpenCode from the intended project after the environment variables are set.
Other clients
Use https://inference.costiq.xyz/v1 as the OpenAI-compatible base URL, your CostIQ key as the API key, and general-fast as the model. Test model discovery, a non-streaming completion, streaming termination, errors, and cancellation before calling a new client supported.