Back to Eliza

OpenAI Plugin

packages/docs/plugin-registry/llm/openai.md

2.0.14.2 KB
Original Source

The OpenAI plugin connects Eliza agents to OpenAI's API, providing access to GPT-5, GPT-5-mini, the o3/o4-mini reasoning model families, DALL-E image generation, and Whisper speech-to-text.

Package: @elizaos/plugin-openai

Installation

bash
eliza plugins install @elizaos/plugin-openai

Or add to eliza.json:

json
{
  "plugins": {
    "allow": ["openai"]
  }
}

Auto-Enable

The plugin auto-enables when OPENAI_API_KEY is present in the environment:

bash
export OPENAI_API_KEY=sk-...

Configuration

Environment VariableRequiredDescription
OPENAI_API_KEYYesAPI key from platform.openai.com
OPENAI_BASE_URLNoCustom base URL (for Azure OpenAI or compatible APIs)
OPENAI_SMALL_MODELNoOverride the small model identifier (default: gpt-5-mini)
OPENAI_LARGE_MODELNoOverride the large model identifier (default: gpt-5)
OPENAI_EMBEDDING_MODELNoOverride the embedding model (default: text-embedding-3-small)
OPENAI_EMBEDDING_URLNoCustom URL for the embedding endpoint
OPENAI_EMBEDDING_API_KEYNoSeparate API key for the embedding endpoint
OPENAI_EMBEDDING_DIMENSIONSNoOverride embedding vector dimensions
OPENAI_IMAGE_DESCRIPTION_MODELNoModel used for image description/vision tasks
OPENAI_IMAGE_DESCRIPTION_MAX_TOKENSNoMax tokens for image description responses
OPENAI_TTS_MODELNoOverride the text-to-speech model
OPENAI_TTS_VOICENoVoice profile for text-to-speech output
OPENAI_TTS_INSTRUCTIONSNoInstructions for text-to-speech voice style
OPENAI_EXPERIMENTAL_TELEMETRYNoEnable experimental telemetry features
OPENAI_BROWSER_BASE_URLNoBrowser-only proxy endpoint base URL (no secrets in the client)
OPENAI_BROWSER_EMBEDDING_URLNoBrowser-only proxy URL for embedding requests

eliza.json Example

json
{
  "auth": {
    "profiles": {
      "default": {
        "provider": "openai",
        "model": "gpt-5"
      }
    }
  }
}

Supported Models

Text Generation

ModelContextBest For
gpt-5200kLatest flagship, default large model
gpt-5-mini200kFast, cost-efficient tasks, default small model
gpt-4o128kMultimodal reasoning
gpt-5-mini128kCost-efficient alternative

Reasoning Models

ModelContextBest For
o1200kDeep reasoning tasks
o1-mini128kFast reasoning
o3200kState-of-the-art reasoning
o3-mini200kEfficient reasoning
o4-mini200kLatest efficient reasoning

Other Capabilities

CapabilityModel
Embeddingstext-embedding-3-small, text-embedding-3-large
Image generationdall-e-3, dall-e-2
Speech-to-textwhisper-1
Text-to-speechtts-1, tts-1-hd
Visiongpt-5 (multimodal)

Model Type Mapping

elizaOS Model TypeOpenAI Model
TEXT_SMALLgpt-5-mini
TEXT_LARGEgpt-5
TEXT_EMBEDDINGtext-embedding-3-small
IMAGEdall-e-3
TRANSCRIPTIONwhisper-1
TEXT_TO_SPEECHgpt-5-mini-tts

Features

  • Streaming responses
  • Function/tool calling
  • Vision (image input with gpt-5)
  • Structured JSON output (response_format: { type: "json_object" })
  • Batch API support
  • Token usage tracking

Usage Example

typescript
// In a plugin or action handler:
const response = await runtime.useModel("TEXT_LARGE", {
  prompt: "Explain quantum entanglement in simple terms.",
  maxTokens: 500,
  temperature: 0.7,
});

Rate Limits and Pricing

Rate limits depend on your OpenAI usage tier. See platform.openai.com/docs/guides/rate-limits for current limits by tier.

Pricing: openai.com/pricing