TensorZero Autopilot is an automated AI engineer that analyzes LLM observability data, optimizes prompts and models, sets up evals, and runs A/B tests. Schedule a demo →
Let’s initialize the OpenAI SDK and point it to the gateway we just launched.
from openai import OpenAIclient = OpenAI(base_url="http://localhost:3000/openai/v1", api_key="not-used")
5
Call the LLM
response = client.chat.completions.create( model="tensorzero::model_name::openai::gpt-5-mini", # or: model="tensorzero::model_name::anthropic::claude-sonnet-4-20250514" # or: Google, AWS, Azure, xAI, vLLM, Ollama, and many more messages=[ { "role": "user", "content": "Tell me a fun fact.", } ],)
Sample Response
ChatCompletion( id='0198d33f-24f6-7cc3-9dd0-62ba627b27db', choices=[ Choice( finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage( content='Sure! Did you know that octopuses have three hearts? Two pump blood to the gills, while the third pumps it to the rest of the body. And, when an octopus swims, the heart that delivers blood to the body actually **stops beating**—which is why they prefer to crawl rather than swim!', refusal=None, role='assistant', annotations=None, audio=None, function_call=None, tool_calls=[] ) ) ], created=1755890789, model='tensorzero::model_name::openai::gpt-5-mini', object='chat.completion', service_tier=None, system_fingerprint='', usage=CompletionUsage( completion_tokens=67, prompt_tokens=13, total_tokens=80, completion_tokens_details=None, prompt_tokens_details=None ), episode_id='0198d33f-24f6-7cc3-9dd0-62cd7028c3d7')
Let’s initialize the OpenAI SDK and point it to the gateway we just launched.
import OpenAI from "openai";const client = new OpenAI({ baseURL: "http://localhost:3000/openai/v1",});
5
Call the LLM
const response = await client.chat.completions.create({ model: "tensorzero::model_name::openai::gpt-5-mini", // or: model: "tensorzero::model_name::anthropic::claude-sonnet-4-20250514", // or: Google, AWS, Azure, xAI, vLLM, Ollama, and many more messages: [ { role: "user", content: "Tell me a fun fact.", }, ],});
Sample Response
{ id: '0198d345-4bd5-79a2-a235-ebaea8c16d91', episode_id: '0198d345-4bd5-79a2-a235-ebbf6eb49cb8', choices: [ { index: 0, finish_reason: 'stop', message: { content: 'Sure! Did you know that honey never spoils? Archaeologists have found pots of honey in ancient Egyptian tombs that are over 3,000 years old—and still perfectly edible!', tool_calls: [], role: 'assistant' } } ], created: 1755891192, model: 'tensorzero::model_name::openai::gpt-5-mini', system_fingerprint: '', service_tier: null, object: 'chat.completion', usage: { prompt_tokens: 13, completion_tokens: 37, total_tokens: 50 }}