SesameSesame

Codex

OpenAI's Codex agent for AI-assisted coding

Codex is OpenAI's coding agent, powered by GPT models. It's fast, capable, and integrates well with the OpenAI ecosystem.

Overview

FeatureDetails
ProviderOpenAI
CLI Toolcodex
Auth MethodsAPI key, ChatGPT Plus/Pro subscription
StrengthsSpeed, broad knowledge, tool use

Authentication

API Key

  1. Get an API key from OpenAI Platform
  2. Add to Sesame:
    • Per-user: Settings → API Keys → OpenAI
    • System-wide: Set OPENAI_API_KEY environment variable

Subscription (ChatGPT Plus/Pro)

Use your ChatGPT Plus ($20/mo) or ChatGPT Pro ($200/mo) subscription:

  1. Enable device code auth in ChatGPT security settings

  2. Install the Codex CLI:

    npm install -g @openai/codex
  3. Run the login command:

    codex login --device-auth
  4. Complete the authentication flow in your browser

  5. Copy the contents of ~/.codex/auth.json

  6. In Sesame: Avatar → Agent Credentials → Codex → Enter tokens

Environment Variables

VariableDescription
OPENAI_API_KEYAPI key for OpenAI

Capabilities

Codex can:

  • Generate code from natural language
  • Complete and edit existing code
  • Explain code functionality
  • Convert between programming languages
  • Write unit tests
  • Debug and fix issues

Best Practices

Effective Prompts

Good: "Create a React component that displays a paginated
       table of users with sorting and filtering capabilities."

Bad: "Make a table"

Iterative Development

Codex works well with iterative prompts:

  1. Start with the basic structure
  2. Add features incrementally
  3. Refine based on output

Code Style

Specify your preferences:

"Following the project's ESLint configuration, add error
 handling to all API routes with proper TypeScript types."

Troubleshooting

"Authentication failed"

  • API key: Verify at OpenAI Platform
  • Subscription: Ensure device code auth is enabled in ChatGPT settings
  • Re-run codex login --device-auth if needed

"Rate limited"

  • API has rate limits based on your tier
  • Subscription users check usage dashboard
  • Wait and retry, or upgrade your plan

"Context length exceeded"

  • GPT-4 has 128K token context
  • For very large codebases, focus on specific files
  • Use targeted prompts

Device auth not working

  1. Go to ChatGPT security settings
  2. Ensure "Device code authentication" is enabled
  3. Try logging out and back in to ChatGPT
  4. Re-run codex login --device-auth

CLI Reference

# Basic usage
codex "Your prompt here"

# Interactive mode
codex --interactive

# Specify model
codex --model gpt-4o "prompt"

Pricing

MethodCost
API (GPT-4o)~$2.50 / 1M input, ~$10 / 1M output
API (GPT-4o-mini)~$0.15 / 1M input, ~$0.60 / 1M output
ChatGPT Plus$20/month
ChatGPT Pro$200/month (higher limits)

For current pricing, see OpenAI Pricing.

On this page