← All docs
OpenAI SDK
Wrap the OpenAI client. Every chat completion, tool call, and assistant run is captured.
Wrap the official OpenAI client with Cisora to instrument every chat completion, embedding, image, and tool call.
Install
npm install @cisora/sdk openaiQuickstart
import OpenAI from 'openai';
import { wrapOpenAI } from '@cisora/sdk/openai';
const openai = wrapOpenAI(new OpenAI(), {
apiKey: process.env.CISORA_API_KEY!,
agentName: 'support-agent',
});
// Use exactly like the standard OpenAI SDK.
const completion = await openai.chat.completions.create({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'hi' }],
});
// Tool calls are captured as nested actions.
const run = await openai.beta.threads.runs.create(threadId, {
assistant_id: 'asst_…',
});What gets captured
- Model name and full message list (prompt input)
- Completion text, finish_reason, refusal
- Prompt + completion + total tokens; auto-computed USD cost
- Tool / function calls nested as child actions
- Streaming aggregated and captured on stream close
- Assistants API: runs, steps, tool calls captured as a trace
Notes
Drop-in compatible
wrapOpenAI returns the same OpenAI client surface. Existing code keeps working — no method signatures change.
Azure OpenAI supported
Pass an Azure OpenAI client to wrapOpenAI() and Cisora captures the deployment name alongside the model.
Next steps
- · REST API reference — full endpoint list
- · Write your first policy — gate unsafe actions
- · SDK reference — methods and options
Alternative approach
Use the Gateway instead
Route OpenAI calls through the Cisora gateway. Your Cisora API key authenticates; the gateway decrypts your OpenAI key server-side and forwards the call.
from openai import OpenAI
client = OpenAI(
api_key="cisora_live_YOUR_KEY", # your Cisora key
base_url="https://cisora.io/api/gateway/openai/v1",
)
# Identical API — streaming and tool calls work
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello"}],
)Gateway setup guide →