Providers

OpenAI

Use GPT-4o, GPT-4, and GPT-3.5 models

🟢

OpenAI

GPT-4o, GPT-4, GPT-3.5 Turbo

OpenAI

The most popular LLM provider. Access GPT-4o, GPT-4 Turbo, and GPT-3.5 models.


Setup

1. Get API Key

Get your API key from platform.openai.com

2. Add Environment Variable

# .env.local
OPENAI_API_KEY=sk-...

3. Configure Provider

<YourGPTProvider
  runtimeUrl="/api/chat"
  llm={{
    provider: 'openai',
    model: 'gpt-4o',
  }}
>
  <CopilotChat />
</YourGPTProvider>

Available Models

ModelContextBest For
gpt-4o128KLatest multimodal, best overall
gpt-4o-mini128KFast & affordable
gpt-4-turbo128KPrevious flagship
gpt-48KOriginal GPT-4
gpt-3.5-turbo16KFast, budget-friendly

Recommended: Use gpt-4o for best quality or gpt-4o-mini for cost efficiency.


Configuration Options

llm={{
  provider: 'openai',
  model: 'gpt-4o',
  temperature: 0.7,        // 0-2, default 1
  maxTokens: 4096,         // Max response length
  topP: 1,                 // Nucleus sampling
  frequencyPenalty: 0,     // -2 to 2
  presencePenalty: 0,      // -2 to 2
}}

Vision (Image Input)

GPT-4o supports image analysis:

const { sendMessage } = useYourGPT();

// Send message with image
sendMessage("What's in this image?", [
  {
    type: 'image',
    data: base64ImageData,
    mimeType: 'image/png',
  }
]);

Tool Calling

OpenAI has excellent tool/function calling support:

useToolWithSchema({
  name: 'search_products',
  description: 'Search for products',
  schema: z.object({
    query: z.string(),
    category: z.string().optional(),
  }),
  handler: async ({ query, category }) => {
    // OpenAI reliably extracts structured parameters
    const results = await searchProducts(query, category);
    return { success: true, data: results };
  },
});

Pricing

ModelInputOutput
gpt-4o$2.50/1M tokens$10/1M tokens
gpt-4o-mini$0.15/1M tokens$0.60/1M tokens
gpt-3.5-turbo$0.50/1M tokens$1.50/1M tokens

Prices as of late 2024. Check OpenAI pricing for current rates.


Next Steps

On this page