Skip to content

[Bug]: Forward prompt_cache_key through the openai-chat adapter #217

Description

@hakilee

Summary

A caller can send prompt_cache_key as an optional string to /v1/responses.

OpenCodex's Responses parser writes the value to options.promptCacheKey.

createOpenAIChatAdapter().buildRequest() builds the outbound /chat/completions body without that value.

The OpenAI Chat Completions Create API lists prompt_cache_key as an optional string.

OpenAI uses the key to group similar requests for prompt caching and improve cache hit rates.

OpenCodex should copy parsed.options.promptCacheKey to body.prompt_cache_key without changing the string.

OpenCodex should omit the upstream field if the caller does not send it.

Reproduction

  1. Add a provider that uses the openai-chat adapter.

  2. Send a Responses request with prompt_cache_key.

    curl http://127.0.0.1:10100/v1/responses \
      -H 'Content-Type: application/json' \
      -d '{
        "model": "example/example-model",
        "input": "Hello",
        "prompt_cache_key": "shared-prefix-v1",
        "stream": false
      }'
  3. Capture the request that OpenCodex sends to the provider's /chat/completions endpoint.

  4. Confirm that the outbound body lacks prompt_cache_key.

Logs and screenshots

src/responses/schema.ts
prompt_cache_key: z.string().optional()

src/responses/parser.ts
options.promptCacheKey = data.prompt_cache_key

src/adapters/openai-chat.ts
createOpenAIChatAdapter().buildRequest() constructs the body without prompt_cache_key

Expected outbound field:
prompt_cache_key="shared-prefix-v1"

Area

Provider adapter

Version

2.7.30

OS

macOS 26.5.2 (arm64)

Config shape

{
  "defaultProvider": "example",
  "providers": {
    "example": {
      "adapter": "openai-chat",
      "baseUrl": "https://example.invalid/v1",
      "authMode": "key",
      "apiKey": "<redacted>",
      "defaultModel": "example-model"
    }
  }
}

Checks

  • I searched existing issues and docs first.
  • I removed secrets, tokens, and personal data from logs and screenshots.

Activity

  1. lidge-jun commented on Jul 21, 2026

    @lidge-jun
    Owner

    Fixed on dev by PR #224 (commit 15d83ba). The openai-chat adapter now forwards prompt_cache_key to the outbound /chat/completions body when set, gated behind a per-provider opt-in (promptCacheKey: true in the registry entry) so strict backends that reject unknown fields are not affected. Omitted when the caller does not send it. Will ship in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions