Package Exports
- @robinpath/openai
Readme
@robinpath/openai
OpenAI module for RobinPath.
Why use this module?
The openai module lets you:
- Send a chat completion request to OpenAI
- Send a legacy completion request
- Generate images using DALL-E
- Edit an image using DALL-E with an optional mask
- Create a variation of an existing image
All functions are callable directly from RobinPath scripts with a simple, consistent API.
Installation
robinpath add @robinpath/openaiQuick Start
1. Set up credentials
openai.setApiKey "sk-..."2. Send a chat completion request to OpenAI
openai.chat "Hello, how are you?" {"model": "gpt-4o"}Available Functions
| Function | Description |
|---|---|
openai.setApiKey |
Set the OpenAI API key for authentication |
openai.chat |
Send a chat completion request to OpenAI |
openai.complete |
Send a legacy completion request |
openai.generateImage |
Generate images using DALL-E |
openai.editImage |
Edit an image using DALL-E with an optional mask |
openai.createImageVariation |
Create a variation of an existing image |
openai.transcribe |
Transcribe audio to text using Whisper |
openai.translate |
Translate audio to English text using Whisper |
openai.speak |
Convert text to speech using TTS |
openai.createEmbedding |
Generate text embeddings |
openai.createModeration |
Check text for content policy violations |
openai.listModels |
List all available OpenAI models |
openai.getModel |
Get details of a specific model |
openai.uploadFile |
Upload a file to OpenAI |
openai.listFiles |
List uploaded files |
openai.deleteFile |
Delete an uploaded file |
openai.getFileContent |
Get the content of an uploaded file |
openai.createFineTune |
Create a fine-tuning job |
openai.listFineTunes |
List fine-tuning jobs |
openai.getFineTune |
Get details of a fine-tuning job |
openai.cancelFineTune |
Cancel a running fine-tuning job |
openai.createBatch |
Create a batch processing request |
openai.getBatch |
Get details of a batch request |
openai.listBatches |
List batch requests |
openai.cancelBatch |
Cancel a batch request |
Examples
Send a chat completion request to OpenAI
openai.chat "Hello, how are you?" {"model": "gpt-4o"}Send a legacy completion request
openai.complete "Once upon a time"Generate images using DALL-E
openai.generateImage "A sunset over mountains" {"model": "dall-e-3", "size": "1024x1024"}Integration with RobinPath
import { RobinPath } from "@wiredwp/robinpath";
import Module from "@robinpath/openai";
const rp = new RobinPath();
rp.registerModule(Module.name, Module.functions);
rp.registerModuleMeta(Module.name, Module.functionMetadata);
const result = await rp.executeScript(`
openai.setApiKey "sk-..."
openai.chat "Hello, how are you?" {"model": "gpt-4o"}
`);Full API Reference
See MODULE.md for complete documentation including all parameters, return types, error handling, and advanced examples.
Related Modules
@robinpath/anthropic— Anthropic module for complementary functionality@robinpath/ai— AI module for complementary functionality@robinpath/deepl— DeepL module for complementary functionality@robinpath/translate— Translate module for complementary functionality@robinpath/json— JSON module for complementary functionality
License
MIT