Skip to main content

Overview

The OpenAI provider enables ZeroClaw to use GPT models and reasoning models via the OpenAI API. Provider ID: openai Base URL: https://api.openai.com/v1 API Version: Latest stable

Authentication

Environment Variables

Credentials are resolved in the following order:
  1. OPENAI_API_KEY - OpenAI API key
  2. Generic fallback: ZEROCLAW_API_KEY or API_KEY

API Key Format

Standard API keys use the format sk-*:

Configuration

Config File

Custom Base URL

For compatible endpoints:

Max Tokens Override

Optional per-provider override:

Features

Native Tool Calling

Supported: Yes The provider uses OpenAI’s native function calling format:

Vision Support

Supported: Yes (model-dependent) Vision models like gpt-4o support image inputs. ZeroClaw does not currently parse inline images for OpenAI (vision support via multimodal normalization is provider-specific).

Reasoning Models

Supported: Yes Reasoning models (e.g., o1, o1-mini) return output in reasoning_content field:
ZeroClaw automatically extracts:
  • content → primary response
  • reasoning_content → fallback if content is empty

Token Usage Tracking

Supported: Yes Usage data is extracted from response:
Mapped to ZeroClaw’s TokenUsage:

API Endpoints

Chat Completion

Endpoint: POST /chat/completions Request:
Response:

Models Endpoint

Endpoint: GET /models Used for warmup:

Request Configuration

Max Tokens

Default: Not set (uses model default) Override: Optional via max_tokens_override

Temperature

Range: 0.0 - 2.0 Default: 0.7 (from config) Controls response randomness.

Timeouts

  • Request timeout: 120 seconds
  • Connection timeout: 10 seconds

Message Format

System Prompt

Sent as a message with role system:

User Messages

Simple text:

Assistant Messages

Text only:
With tool calls:
With reasoning content:

Tool Messages

Tool results:

Tool Call Conversion

ZeroClaw’s internal tool format is converted to OpenAI format: ZeroClaw internal:
Sent to OpenAI:

Stop Reasons

Normalized stop reasons:

Error Handling

Authentication Errors

Solution: Export OPENAI_API_KEY.

Invalid Tool Specification

Strict validation for tool definitions:
Tools must have:
  • type: "function"
  • function.name (string)
  • function.description (string, can be empty)
  • function.parameters (object)

API Errors

Error responses are sanitized before display:

Provider Capabilities

Vision support depends on the specific model (e.g., gpt-4o).

Warmup

Supported: Yes Warmup calls the /models endpoint:
Successful warmup establishes TLS and verifies credentials.

Example Usage

Simple Chat

With Tools

Reasoning Model

Reasoning Content Handling

Reasoning models may return:
ZeroClaw extracts:
This ensures reasoning output is never lost.

Limitations

  • Max tokens override is optional (not all requests use it)
  • Vision support is model-dependent (not auto-detected)
  • Reasoning content pass-through in multi-turn history
  • Tool validation is strict (malformed tools are rejected)