Skip to content

fix: correct prompt_cache_retention literal from "in-memory" to "in_memory"#2946

Open
giulio-leone wants to merge 1 commit intoopenai:mainfrom
giulio-leone:fix/prompt-cache-retention-type
Open

fix: correct prompt_cache_retention literal from "in-memory" to "in_memory"#2946
giulio-leone wants to merge 1 commit intoopenai:mainfrom
giulio-leone:fix/prompt-cache-retention-type

Conversation

@giulio-leone
Copy link

Summary

Fixes #2883

The Literal type for prompt_cache_retention used "in-memory" (hyphen) but the OpenAI API expects "in_memory" (underscore). Using the SDK-typed value caused 400 Bad Request errors from the API.

Changes

Replaced all 41 occurrences of "in-memory""in_memory" across:

Type definitions

  • src/openai/types/responses/response_create_params.py
  • src/openai/types/responses/response.py
  • src/openai/types/responses/responses_client_event.py
  • src/openai/types/responses/responses_client_event_param.py
  • src/openai/types/chat/completion_create_params.py

Method signatures

  • src/openai/resources/chat/completions/completions.py
  • src/openai/resources/responses/responses.py

Tests

  • tests/api_resources/chat/test_completions.py
  • tests/api_resources/test_responses.py

Reproduction

As described in #2883, passing prompt_cache_retention="in-memory" (the SDK-typed value) returns a 400 error, while "in_memory" succeeds.

…emory"

The Literal type for prompt_cache_retention used "in-memory" (hyphen) but the
OpenAI API expects "in_memory" (underscore). Using the SDK-typed value caused
400 errors from the API.

Updated all type definitions, method signatures, and tests across:
- types/responses/response_create_params.py
- types/responses/response.py
- types/responses/responses_client_event.py
- types/responses/responses_client_event_param.py
- types/chat/completion_create_params.py
- resources/chat/completions/completions.py
- resources/responses/responses.py
- tests/api_resources/chat/test_completions.py
- tests/api_resources/test_responses.py

Fixes openai#2883
@giulio-leone giulio-leone requested a review from a team as a code owner March 9, 2026 10:32
@giulio-leone
Copy link
Author

Friendly ping — CI is green, tests pass, rebased on latest. Ready for review whenever convenient. Happy to address any feedback. 🙏

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

prompt_cache_retention type declares "in-memory" but API expects "in_memory"

1 participant