This integration method is maintained but no longer actively developed. For the best experience and latest features, use our new AI Gateway with unified API access to 100+ models.
1
2
HELICONE_API_KEY=<your-helicone-api-key>
OPENAI_API_KEY=<your-openai-api-key>
3
import OpenAI from "openai";
const openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
baseURL: "https://oai.helicone.ai/v1",
defaultHeaders: {
"Helicone-Auth": `Bearer ${process.env.HELICONE_API_KEY}`
}
});
4
Replace the response’s model, input, and output with content relevant to your application.
const textInputResponse = await openai.responses.create({
model: "gpt-4.1",
input: "What is the meaning of life?"
});
console.log(textInputResponse);
const imageInputResponse = await openai.responses.create({
model: "gpt-4.1",
input: [
{
role: "user",
content: [
{ type: "input_text", text: "what is in this image?" },
{
type: "input_image",
image_url:
"https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",
},
],
},
],
});
console.log(imageInputResponse);
const jsonInputResponse = await openai.responses.create({
model: "gpt-4.1",
input: { name: "John", age: 30 }
});
console.log(jsonInputResponse);
const webSearchResponse = await openai.responses.create({
model: "gpt-4.1",
tools: [{ type: "web_search_preview" }],
input: "What was a positive news story from today?",
});
console.log(webSearchResponse);
const fileSearchResponse = await openai.responses.create({
model: "gpt-4.1",
tools: [{
type: "file_search",
vector_store_ids: ["vs_1234567890"],
max_num_results: 20
}],
input: "What are the attributes of an ancient brown dragon?",
});
console.log(fileSearchResponse);
const streamingResponse = await openai.responses.create({
model: "gpt-4.1",
instructions: "You are a helpful assistant.",
input: "Hello!",
stream: true,
});
for await (const event of streamingResponse) {
console.log(event);
}
const tools = [
{
type: "function" as const,
name: "get_current_weather",
description: "Get the current weather in a given location",
parameters: {
type: "object",
properties: {
location: {
type: "string",
description: "The city and state, e.g. San Francisco, CA"
},
unit: { type: "string", enum: ["celsius", "fahrenheit"] }
},
required: ["location", "unit"]
},
strict: true
},
];
const functionCallingResponse = await openai.responses.create({
model: "gpt-4.1",
tools: tools,
input: "What is the weather like in Boston today?",
tool_choice: "auto"
});
console.log(functionCallingResponse);
const reasoningResponse = await openai.responses.create({
model: "o3-mini",
input: "How much wood would a woodchuck chuck?",
reasoning: {
effort: "high"
}
});
console.log(reasoningResponse);
5