# OpenAI

This documentation covers two authentication approaches for OpenAI access within the Codex platform.

## Authentication Options

**API Key Method**: Users can configure direct API access through OpenAI's platform using usage-based billing. Setup requires obtaining credentials from the OpenAI dashboard and running the onboarding wizard with the appropriate flag.

**ChatGPT Subscription Method**: An alternative approach leverages existing ChatGPT or Codex subscriptions rather than direct API credentials. This method requires OAuth authentication through the Codex CLI or cloud interface.

## Configuration Details

Both approaches require specifying a model reference in the format `provider/model`. Model refs always use `provider/model`.

## Setup Process

The onboarding CLI accepts either direct API key input or interactive authentication selection. Users can bypass the interactive wizard by providing credentials as command-line arguments during setup.

```bash
openclaw onboard --auth-choice openai-api-key
```

Or with the API key directly:

```bash
openclaw onboard --openai-api-key "$OPENAI_API_KEY"
```

## Config snippet

```json5
{
  env: { OPENAI_API_KEY: "sk-..." },
  agents: { defaults: { model: { primary: "openai/gpt-4o" } } },
}
```
