@openpets/openai
v1.0.3
Published
Access OpenAI's powerful APIs including GPT models, DALL-E, Whisper, and more through OpenPets.
Maintainers
Readme
OpenAI Pet
Access OpenAI's powerful APIs including GPT models, DALL-E, Whisper, and more through OpenPets.
Quick Start
1. Get an API Key
- Go to platform.openai.com/api-keys
- Create a new API key
- Copy the key
2. Configure Environment
cp .env.example .env
# Edit .env and add your API keyOr set the environment variable directly:
export OPENAI_API_KEY="sk-..."3. Test Connection
opencode run "test openai connection"Available Tools
Core Tools (Always Loaded)
These 21 tools are always available when configured:
| Category | Tools |
|----------|-------|
| Chat | openai-create-chat-completion, openai-list-chat-completions, openai-get-chat-completion, etc. |
| Audio | openai-create-speech, openai-create-transcription, openai-create-translation, etc. |
| Images | openai-create-image, openai-create-image-edit, openai-create-image-variation |
| Models | openai-list-models, openai-retrieve-model, openai-delete-model |
Additional Tool Groups (LoadEnv)
Enable additional tool groups via environment variables:
# Enable file management tools (5 tools)
export OPENAI_LOAD_FILES_TOOLS=true
# Enable fine-tuning tools (13 tools)
export OPENAI_LOAD_FINE_TUNING_TOOLS=true
# Enable embeddings tools (1 tool)
export OPENAI_LOAD_EMBEDDINGS_TOOLS=true
# Enable realtime/voice tools (8 tools)
export OPENAI_LOAD_REALTIME_TOOLS=true
# Enable video generation tools (6 tools)
export OPENAI_LOAD_VIDEOS_TOOLS=true
# Enable organization/admin tools
export OPENAI_LOAD_PROJECTS_TOOLS=true
export OPENAI_LOAD_USERS_TOOLS=true
export OPENAI_LOAD_GROUPS_TOOLS=trueExample Usage
Chat Completions
opencode run "create a chat completion asking what the capital of France is"List Models
opencode run "list all available openai models"Generate Images
opencode run "generate an image of a sunset over mountains"Transcribe Audio
opencode run "transcribe the audio file at /path/to/audio.mp3"Text to Speech
opencode run "create speech from the text 'Hello world' using the alloy voice"Environment Variables
Required
| Variable | Description |
|----------|-------------|
| OPENAI_API_KEY | Your OpenAI API key from platform.openai.com |
Optional
| Variable | Description |
|----------|-------------|
| OPENAI_ORGANIZATION | Organization ID for API requests |
| OPENAI_HOST | Custom API host (default: https://api.openai.com/v1) |
Tool Group Toggles
| Variable | Description |
|----------|-------------|
| OPENAI_LOAD_FILES_TOOLS | Enable file upload/management tools |
| OPENAI_LOAD_FINE_TUNING_TOOLS | Enable fine-tuning job tools |
| OPENAI_LOAD_EMBEDDINGS_TOOLS | Enable embedding generation tools |
| OPENAI_LOAD_REALTIME_TOOLS | Enable realtime/voice API tools |
| OPENAI_LOAD_VIDEOS_TOOLS | Enable video generation tools |
| OPENAI_LOAD_COMPLETIONS_TOOLS | Enable legacy completions API |
| OPENAI_LOAD_MODERATIONS_TOOLS | Enable content moderation tools |
| OPENAI_LOAD_CONVERSATIONS_TOOLS | Enable conversation management |
| OPENAI_LOAD_RESPONSES_TOOLS | Enable response management |
| OPENAI_LOAD_UPLOADS_TOOLS | Enable large file upload tools |
| OPENAI_LOAD_EVALS_TOOLS | Enable evaluation tools |
| OPENAI_LOAD_PROJECTS_TOOLS | Enable project management tools |
| OPENAI_LOAD_USERS_TOOLS | Enable user management tools |
| OPENAI_LOAD_GROUPS_TOOLS | Enable group management tools |
| OPENAI_LOAD_ROLES_TOOLS | Enable role management tools |
| OPENAI_LOAD_INVITES_TOOLS | Enable invite management tools |
| OPENAI_LOAD_CERTIFICATES_TOOLS | Enable certificate management tools |
| OPENAI_LOAD_AUDIT_LOGS_TOOLS | Enable audit log tools |
| OPENAI_LOAD_USAGE_TOOLS | Enable usage statistics tools |
Tool Statistics
- Total Tools: 171
- Core Tools: 21 (always loaded)
- LoadEnv Tools: 150 (require env var)
- Read-Only Tools: 69
- Write Tools: 102
Regenerating Tools
The OpenAPI tools are auto-generated from OpenAI's official specification. To regenerate:
cd pets/openai
pets generate-openapi --verboseThis fetches the latest spec from OpenAI and regenerates openapi-client.ts.
FAQ
How do I get an OpenAI API key?
Go to platform.openai.com/api-keys and create a new API key. You'll need an OpenAI account with billing enabled.
What models are available?
Use the openai-list-models tool to see all available models including GPT-4, GPT-3.5-turbo, DALL-E 3, Whisper, and more.
Why are some tools not showing?
By default only core tools (Chat, Audio, Images, Models) are loaded. Enable additional tool groups via environment variables like OPENAI_LOAD_FILES_TOOLS=true.
Can I use a custom API endpoint?
Yes, set OPENAI_HOST to your custom endpoint (e.g., for Azure OpenAI or a proxy).
How do I enable all tools?
Set all the OPENAI_LOAD_*_TOOLS=true environment variables, or add them to your .env file.
