Other Clients

OpenAI SDK

Quick answer
The official OpenAI SDKs work with Prism unchanged apart from the base URL. Set base_url to http://127.0.0.1:11434/v1 and the API key to prism, then use any model from your catalog. Both chat.completions and responses are supported, with streaming.

Last updated Reviewed against Prism v0.3.26

Python

from openai import OpenAI

client = OpenAI(
    base_url="http://127.0.0.1:11434/v1",
    api_key="prism",
)

stream = client.chat.completions.create(
    model="glm-5.1:cloud",
    messages=[{"role": "user", "content": "Explain this stack trace."}],
    stream=True,
)

for chunk in stream:
    delta = chunk.choices[0].delta.content
    if delta:
        print(delta, end="", flush=True)

Node.js

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "http://127.0.0.1:11434/v1",
  apiKey: "prism",
});

const stream = await client.chat.completions.create({
  model: "glm-5.1:cloud",
  messages: [{ role: "user", content: "Explain this stack trace." }],
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}

Using the Responses API

The SDK's Responses surface maps to Prism's /v1/responses endpoint. Use it when you want typed output items, built-in tool calling shapes, or a model that only speaks Responses upstream — Prism translates either direction.

resp = client.responses.create(
    model="glm-5.1:cloud",
    input="Summarise the last commit.",
)
print(resp.output_text)

Choosing the model name

What you passWhat Prism does
A model in your catalogRoutes to that model's provider with its configured protocol.
An aliasRewrites to the alias target, then resolves as above.
An unknown nameFalls back to your default model.

Call client.models.list() to see exactly what Prism offers — the endpoint needs no authentication and returns your routed catalog. See API Formats.

Tool calls and images work
Function calling, structured outputs, vision input and reasoning fields all translate across the three formats. If your code relies on a specific OpenAI response shape, it will still see that shape — Prism presents each client with the dialect it asked for.

Environment-variable configuration

The SDKs read OPENAI_BASE_URL and OPENAI_API_KEY. Setting those two routes any SDK-based tool through Prism with no code change at all — which is also how most unrecognised local tools can be redirected.

export OPENAI_BASE_URL="http://127.0.0.1:11434/v1"
export OPENAI_API_KEY="prism"