OpenAI SDK

Wrap OpenAI clients for use with the Reminix runtime

The OpenAI adapter wraps an OpenAI client for use with the Reminix runtime.

Installation

npm install @reminix/runtime @reminix/adapters openai
# or
pnpm add @reminix/runtime @reminix/adapters openai

Usage

import OpenAI from 'openai';
import { fromOpenAI } from '@reminix/adapters/openai';
import { serve } from '@reminix/runtime';

const client = new OpenAI();
const agent = fromOpenAI(client, {
  name: 'gpt4-agent',
  model: 'gpt-4o',
  system: 'You are a helpful assistant.',
});

serve(agent);

Options

ParameterTypeDefaultDescription
namestringrequiredName for the Reminix agent
modelstring"gpt-4o"The model to use
systemstringundefinedOptional system prompt
metadataRecord<string, unknown>undefinedOptional metadata for the agent

Handler Mapping

Reminix HandlerOpenAI Method
onInvokeclient.chat.completions.create({ stream: false })
onInvokeStreamclient.chat.completions.create({ stream: true })
onChatclient.chat.completions.create({ stream: false })
onChatStreamclient.chat.completions.create({ stream: true })

Example: Multi-turn Chat

import OpenAI from 'openai';
import { fromOpenAI } from '@reminix/adapters/openai';
import { serve } from '@reminix/runtime';

const client = new OpenAI();
const agent = fromOpenAI(client, {
  name: 'conversational-agent',
  model: 'gpt-4o',
  system: 'You are a friendly conversational AI. Remember context from previous messages.',
});

serve(agent, { port: 8080 });

Test with:

curl -X POST http://localhost:8080/agent/conversational-agent/chat \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [
      {"role": "user", "content": "My name is Alice."},
      {"role": "assistant", "content": "Nice to meet you, Alice!"},
      {"role": "user", "content": "What is my name?"}
    ]
  }'

On this page