openai / Exports / IOpenAIProviderOptions
Interface: IOpenAIProviderOptions
OpenAI provider options
Hierarchy
↳
IOpenAIProviderOptions
Table of contents
Properties
Properties
apiKey
• Optional apiKey: string
OpenAI API key (required when client is not provided)
Defined in
organization
• Optional organization: string
OpenAI organization ID (optional)
Defined in
timeout
• Optional timeout: number
API request timeout (milliseconds)
Defined in
baseURL
• Optional baseURL: string
API base URL (default: 'https://api.openai.com/v1')
Defined in
responseFormat
• Optional responseFormat: "text" | "json_object" | "json_schema"
Response format (default: 'text')
- 'text': Plain text response
- 'json_object': JSON object mode (requires system message)
- 'json_schema': Structured Outputs with schema validation
Defined in
jsonSchema
• Optional jsonSchema: Object
JSON schema for structured outputs (required when responseFormat is 'json_schema')
Type declaration
| Name | Type |
|---|---|
name | string |
description? | string |
schema? | Record<string, TProviderOptionValue> |
strict? | boolean |
Defined in
client
• Optional client: OpenAI
OpenAI client instance (optional: will be created from apiKey if not provided)
Defined in
payloadLogger
• Optional payloadLogger: IPayloadLogger
Payload logger instance for debugging API requests/responses
Use different implementations based on your environment:
- FilePayloadLogger: Node.js file-based logging
- ConsolePayloadLogger: Browser console-based logging
- Custom: Implement IPayloadLogger interface
Example
// Node.js
import { FilePayloadLogger } from '@robota-sdk/agent-provider-openai/loggers/file';
const provider = new OpenAIProvider({
client: openaiClient,
payloadLogger: new FilePayloadLogger({ logDir: './logs/openai' }),
});
// Browser
import { ConsolePayloadLogger } from '@robota-sdk/agent-provider-openai/loggers/console';
const provider = new OpenAIProvider({
client: openaiClient,
payloadLogger: new ConsolePayloadLogger(),
});Defined in
executor
• Optional executor: IExecutor
Optional executor for handling AI requests
When provided, the provider will delegate all chat operations to this executor instead of making direct API calls. This enables remote execution capabilities.
Example
import { LocalExecutor, RemoteExecutor } from '@robota-sdk/agent-core';
// Local execution (registers this provider)
const localExecutor = new LocalExecutor();
localExecutor.registerProvider('openai', new OpenAIProvider({ apiKey: 'sk-...' }));
// Remote execution
const remoteExecutor = new RemoteExecutor({
serverUrl: 'https://api.robota.io',
userApiKey: 'user-token-123',
});
const provider = new OpenAIProvider({
executor: remoteExecutor, // No direct API key needed
});Defined in
logger
• Optional logger: AbstractLogger
Logger instance for internal OpenAI provider logging
Default Value
SilentLogger;