Installation
npm install @reminix/openai openai
Requires openai version 6.16.0 or later as a peer dependency.
Chat Agent
Use OpenAIChatAgent for conversational agents with streaming support.
import OpenAI from "openai"
import { OpenAIChatAgent } from "@reminix/openai"
import { serve } from "@reminix/runtime"
const openai = new OpenAI ()
const chatbot = new OpenAIChatAgent ( openai , {
name: "chatbot" ,
instructions: "You are a helpful assistant." ,
})
serve ({ agents: [ chatbot ] })
The default model is gpt-4o-mini. Override it with the model option:
const chatbot = new OpenAIChatAgent ( openai , {
name: "chatbot" ,
model: "gpt-4o" ,
instructions: "You are a helpful assistant." ,
})
Streaming
Chat agents support streaming out of the box:
import Reminix from "@reminix/sdk"
const client = new Reminix ()
const stream = await client . agents . chat ( "chatbot" , {
messages: [{ role: "user" , content: "Hello!" }],
stream: true ,
})
for await ( const event of stream ) {
if ( event . type === "text_delta" ) {
process . stdout . write ( event . delta )
}
}
Task Agent
Use OpenAITaskAgent for structured output with a defined schema.
import OpenAI from "openai"
import { OpenAITaskAgent } from "@reminix/openai"
import { serve } from "@reminix/runtime"
const openai = new OpenAI ()
const analyzer = new OpenAITaskAgent ( openai , {
name: "analyzer" ,
instructions: "Analyze the sentiment of the given text." ,
outputSchema: {
type: "object" ,
properties: {
sentiment: { type: "string" , enum: [ "positive" , "negative" , "neutral" ] },
confidence: { type: "number" },
},
required: [ "sentiment" , "confidence" ],
},
})
serve ({ agents: [ analyzer ] })
Options
The first argument to all OpenAI agent constructors is an OpenAI client instance.
Agent name. Used as the endpoint identifier.
OpenAI model to use. Defaults to gpt-4o-mini.
System prompt for the model.
Agent description for discovery and documentation.
Output schema for task agents. Defines the structured output format.
Tags for filtering and organizing agents.
Additional metadata attached to the agent.
Next steps
Deploying Ship your OpenAI agent to production.
Configuration & Secrets Where to put your OPENAI_API_KEY.
Anthropic Same flow with the Anthropic SDK.
Python: OpenAI The same integration in Python.