npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@humanlayer/agentlayer-provider-openai-codex

v0.0.54

Published

OpenAI Codex provider for AgentLayer and the AI SDK. It talks to the ChatGPT Codex responses endpoint and supports ChatGPT OAuth/API-key auth through `@humanlayer/agentlayer-provider-auth`.

Readme

agentlayer-provider-openai-codex

OpenAI Codex provider for AgentLayer and the AI SDK. It talks to the ChatGPT Codex responses endpoint and supports ChatGPT OAuth/API-key auth through @humanlayer/agentlayer-provider-auth.

Installation

bun add @humanlayer/agentlayer-provider-openai-codex @humanlayer/agentlayer-provider-auth

Providers

This package exports three provider implementations, each with different tradeoffs:

1. createCodexProvider — Full hand-rolled SSE

The original provider. Implements full SSE byte-stream parsing, event dispatch, and a 120-second per-chunk watchdog timer (readWithTimeout). Does not depend on @ai-sdk/openai for streaming.

import { createCodexProvider } from '@humanlayer/agentlayer-provider-openai-codex'

const codex = createCodexProvider({ /* auth options */ })
const model = codex.languageModel('codex-mini-latest')

Pros: Battle-tested, built-in 120s per-chunk watchdog, full control over SSE parsing. Cons: Custom SSE parser must track upstream protocol changes manually.

2. createCodexResponsesProvider — Thin wrapper over @ai-sdk/openai

Delegates all SSE parsing to @ai-sdk/openai's responses() implementation. Only handles auth, headers, URL rewriting, and request body cleanup. Includes a configurable per-chunk watchdog (wrapSSE) that wraps the response body stream.

import { createCodexResponsesProvider } from '@humanlayer/agentlayer-provider-openai-codex'

const codex = createCodexResponsesProvider({ /* auth options */ })
const model = codex.languageModel('codex-mini-latest')

Pros: Stays current with @ai-sdk/openai protocol changes automatically, configurable chunk timeout. Cons: Depends on @ai-sdk/openai's parsing behavior.

Options:

| Option | Default | Effect | | --- | --- | --- | | chunkTimeout | 120000 (2 min) | Per-chunk SSE timeout in ms. Set to false or 0 to disable. |

3. createCodexEffectProvider — Effect-based protocol parser (vendored from opencode)

Uses the OpenAI Responses protocol parser from opencode, vendored as an Effect-based state machine. Builds the request body directly, sends via the same codex auth layer, and parses SSE events through the opencode protocol's step() function. Includes the same configurable per-chunk watchdog.

import { createCodexEffectProvider } from '@humanlayer/agentlayer-provider-openai-codex'

const codex = createCodexEffectProvider({ /* auth options */ })
const model = codex.languageModel('codex-mini-latest')

Pros: Battle-tested protocol parser from opencode, handles edge cases in the OpenAI Responses stream format, Effect-based state machine for structured event parsing. Cons: Adds effect as a dependency (~vendored from opencode, @ts-nocheck on vendored protocol file due to tsconfig differences).

Options:

| Option | Default | Effect | | --- | --- | --- | | chunkTimeout | 120000 (2 min) | Per-chunk SSE timeout in ms. Set to false or 0 to disable. |

Common Options

All three providers accept the same base options:

interface CodexProviderOptions {
  authStore?: AuthStore       // Auth store for OAuth/API key management
  providerId?: string         // Provider ID in the auth store (default: 'codex')
  fetch?: CodexFetchLike      // Custom fetch implementation
  version?: string            // Codex CLI version to report in User-Agent
  sessionId?: string          // Session ID header
  now?: () => number          // Clock override for token expiry checks
  fastMode?: boolean          // Send service_tier: "priority"
  serviceTier?: string | null // Explicit service tier
}

Fast Mode

Codex CLI fast mode sends service_tier: "priority" in the request body. All three providers expose the same behavior with fastMode: true.

const codex = createCodexProvider({
  authStore: createMemoryAuthStore({
    codex: {
      kind: 'oauth',
      accessToken: process.env.CODEX_ACCESS_TOKEN!,
      accountId: process.env.CHATGPT_ACCOUNT_ID,
    },
  }),
  fastMode: true,
})

const model = codex.languageModel('gpt-5.4')

You can also enable it per request through provider options:

await model.doStream({
  prompt: [{ role: 'user', content: [{ type: 'text', text: 'Ship this quickly.' }] }],
  providerOptions: {
    codex: {
      fastMode: true,
    },
  },
})

If you need to set the tier explicitly, use serviceTier. The alias "fast" is normalized to Codex's API value "priority".

await model.doStream({
  prompt: [{ role: 'user', content: [{ type: 'text', text: 'Use the priority tier.' }] }],
  providerOptions: {
    codex: {
      serviceTier: 'fast', // sends service_tier: 'priority'
    },
  },
})

serviceTier takes precedence over fastMode, which lets callers opt into "flex" or clear the tier explicitly when needed.

Provider Options

Both openai and codex provider option namespaces are accepted for request-level options.

| Option | Effect | | --- | --- | | fastMode: true | Sends service_tier: "priority" | | serviceTier: "fast" | Sends service_tier: "priority" | | serviceTier: "priority" | Sends service_tier: "priority" | | serviceTier: "flex" | Sends service_tier: "flex" |