Skip to content

feat(api): add service-account API key expiration fields - #3802

Merged
marcuswood-oai merged 3 commits into
mainfrom
castiron/promotions/pr-84
Sep 8, 2026
Merged

feat(api): add service-account API key expiration fields#3802
marcuswood-oai merged 3 commits into
mainfrom
castiron/promotions/pr-84

Conversation

@jbeckwith-oai

@jbeckwith-oai jbeckwith-oai commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds optional expiration fields for service-account API keys, clarifies the Responses store option, and honors WebSocket retry limits across repeated reconnects.

Changes

  • Allow service-account API key creation requests to specify expires_in_seconds.
  • Expose expires_at on service-account API key responses.
  • Clarify the default and retention behavior of the Responses store option.
  • Honor the configured retry limit when WebSocket connections repeatedly fail before receiving a non-error application event.

Castiron-Internal-PR: openai/openai-python-internal#84
Castiron-Source-SHA: 6eefcc34b79ca8c3087a3f6ee6fbbaf5b8ac7510
Castiron-Public-Base-SHA: 2a98f6a
@jbeckwith-oai
jbeckwith-oai marked this pull request as ready for review September 5, 2026 00:40
@jbeckwith-oai
jbeckwith-oai requested a review from a team as a code owner September 5, 2026 00:40
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Castiron custom code

✅ No new custom-code files detected.

36 mixed files remain; 0 existing customizations changed; 5 generated baselines changed.

Compared 182af73b39992bdf7d7a1d37. Generated baselines verified.

File Result Current custom patch
src/openai/resources/beta/responses/responses.py Generated baseline changed +12 / −11
src/openai/resources/realtime/realtime.py Generated baseline changed +65 / −32
src/openai/resources/responses/responses.py Generated baseline changed +851 / −18
src/openai/types/responses/responses_client_event.py Generated baseline changed +30 / −0
src/openai/types/responses/responses_client_event_param.py Generated baseline changed +30 / −0
31 existing customizations unchanged
  • api.md
  • scripts/castiron/README.md
  • scripts/castiron/custom_code_report.py
  • scripts/castiron/test_custom_code_report.py
  • src/openai/init.py
  • src/openai/_client.py
  • src/openai/resources/audio/transcriptions.py
  • src/openai/resources/audio/translations.py
  • src/openai/resources/beta/beta.py
  • src/openai/resources/beta/threads/runs/runs.py
  • src/openai/resources/beta/threads/threads.py
  • src/openai/resources/chat/completions/completions.py
  • src/openai/resources/embeddings.py
  • src/openai/resources/files.py
  • src/openai/resources/uploads/uploads.py
  • src/openai/resources/vector_stores/file_batches.py
  • src/openai/resources/vector_stores/files.py
  • src/openai/resources/videos.py
  • src/openai/resources/webhooks/init.py
  • src/openai/resources/webhooks/webhooks.py
  • src/openai/types/chat/init.py
  • src/openai/types/chat/chat_completion_message_tool_call.py
  • src/openai/types/fine_tuning/fine_tuning_job_integration.py
  • src/openai/types/responses/init.py
  • src/openai/types/responses/response.py
  • src/openai/types/responses/response_function_web_search.py
  • src/openai/types/responses/response_function_web_search_param.py
  • src/openai/types/responses/tool.py
  • src/openai/types/responses/tool_param.py
  • src/openai/types/webhooks/init.py
  • tests/api_resources/test_videos.py

A changed generated baseline means this report cannot reliably identify which handwritten lines changed.

Inspect the custom-code diff

Download the exact patch produced by this run (requires repository access):

gh run download 34272245772 --repo openai/openai-python \
  --name castiron-custom-code-34272245772-1 --dir /tmp/castiron-custom-code-34272245772-1
git apply --stat /tmp/castiron-custom-code-34272245772-1/custom-code.patch
cat /tmp/castiron-custom-code-34272245772-1/custom-code.patch

Or reproduce it from an SDK checkout containing the vendored reporter:

git fetch --no-tags origin 182af73b39998d51ad672bbd9c200ee3f4121fad 2bdf7d7a1d3781b5281d5517efb5883f5a7d07cc
python3 scripts/castiron/custom_code_report.py report \
  --base 182af73b39998d51ad672bbd9c200ee3f4121fad \
  --head 2bdf7d7a1d3781b5281d5517efb5883f5a7d07cc --fetch --require-head-hash --public \
  --out /tmp/castiron-custom-code-2bdf7d7a1d37
cat /tmp/castiron-custom-code-2bdf7d7a1d37/custom-code.patch

This is the current full custom patch for mixed files, not an attribution of only the handwritten lines changed by this PR.

Full report and patch

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 5, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-08T19:54:43.905457Z 965ab89 New commits
🔒 Security Review Completed 2026-09-08T19:55:49.990369Z 965ab89 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openai-sdks

openai-sdks Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

OkTest Summary

236/236 SDK tests passed in 9.366s for Python SDK PR #3802.

Test results — 42 files
Test Result Time
tests/chat-completions-complex-body.test.ts ✅ Passed 188ms
tests/chat-completions-create.test.ts ✅ Passed 201ms
tests/chat-completions-stream.test.ts ✅ Passed 112ms
tests/files-content-binary.test.ts ✅ Passed 191ms
tests/files-create-multipart.test.ts ✅ Passed 195ms
tests/files-list-pagination.test.ts ✅ Passed 169ms
tests/initialize-config.test.ts ✅ Passed 152ms
tests/instance-isolation.test.ts ✅ Passed 131ms
tests/models-list.test.ts ✅ Passed 189ms
tests/responses-background-lifecycle.test.ts ✅ Passed 158ms
tests/responses-body-method-errors.test.ts ✅ Passed 261ms
tests/responses-cancel-timeout.test.ts ✅ Passed 177ms
tests/responses-cancel.test.ts ✅ Passed 159ms
tests/responses-compact-retries.test.ts ✅ Passed 260ms
tests/responses-compact.test.ts ✅ Passed 235ms
tests/responses-create-advanced-stream.test.ts ✅ Passed 110ms
tests/responses-create-advanced.test.ts ✅ Passed 177ms
tests/responses-create-disconnect.test.ts ✅ Passed 1.134s
tests/responses-create-errors.test.ts ✅ Passed 155ms
tests/responses-create-malformed-api-responses.test.ts ✅ Passed 144ms
tests/responses-create-retries.test.ts ✅ Passed 235ms
tests/responses-create-stream-failures.test.ts ✅ Passed 133ms
tests/responses-create-stream-timeout.test.ts ✅ Passed 185ms
tests/responses-create-stream-wire.test.ts ✅ Passed 2.959s
tests/responses-create-stream.test.ts ✅ Passed 197ms
tests/responses-create-terminal-states.test.ts ✅ Passed 209ms
tests/responses-create-timeout.test.ts ✅ Passed 173ms
tests/responses-create.test.ts ✅ Passed 400ms
tests/responses-delete.test.ts ✅ Passed 185ms
tests/responses-input-items-errors.test.ts ✅ Passed 253ms
tests/responses-input-items-list.test.ts ✅ Passed 329ms
tests/responses-input-items-options.test.ts ✅ Passed 204ms
tests/responses-input-tokens-count-timeout.test.ts ✅ Passed 222ms
tests/responses-input-tokens-count.test.ts ✅ Passed 211ms
tests/responses-malformed-inputs.test.ts ✅ Passed 2.213s
tests/responses-not-found-errors.test.ts ✅ Passed 201ms
tests/responses-parse.test.ts ✅ Passed 305ms
tests/responses-retrieve-retries.test.ts ✅ Passed 202ms
tests/responses-retrieve.test.ts ✅ Passed 161ms
tests/responses-stored-method-errors.test.ts ✅ Passed 487ms
tests/retry-behavior.test.ts ✅ Passed 3.01s
tests/sdk-error-shape.test.ts ✅ Passed 249ms

View OkTest run #34272216091

SDK merge (9f62bda4ab6c) · head (2bdf7d7a1d37) · base (182af73b3999) · OkTest (08ec4299e769)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7863fba588

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +341 to +342
if isinstance(event_type, str) and event_type and event_type != "error":
self._reconnect_attempt = 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reset retries after recoverable error events

When a successful reconnect is followed by a normal request-level error event, this condition leaves the previous attempt count active even though RealtimeErrorEvent explicitly documents that most errors are recoverable and the session remains open. If that healthy session later experiences an unrelated network disconnect before producing a non-error event, reconnection starts from the stale count and can eventually be refused after several independent incidents. Distinguish admission failures from recoverable application errors instead of treating every type == "error" event as a failed reconnect; the same condition is duplicated in the sync and Responses connection implementations.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the actual sync/async Realtime, Responses, and beta Responses connection classes. For Realtime, session.created is the first event on an established connection; it resets the count before later recoverable errors. A probe starting at the retry limit, receiving that event and then a request error, reconnects at attempt 1 after a later network close.

For a Responses connection that has received only errors since reconnecting, your observation about retaining the count is correct. This guard currently requires a non-error application event (such as response.created) to replenish the budget. Error events remain available to the caller and do not themselves close the connection or consume another retry. Resetting on a subset of errors needs a reliable distinction from errors followed by admission failure/closure, so I am preserving the current behavior pending maintainer agreement on that policy rather than adding an unverified classification. Leaving this thread open for that decision.

@sylvesterkaczmarek sylvesterkaczmarek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reconnect counter is reset only in recv() after the parsed event is known to be non-error. The byte-oriented receive path still calls recv_bytes() directly, so a caller using that public API can successfully receive frames after a reconnect without ever clearing _reconnect_attempt. Separate transient disconnects would then consume one shared retry budget across otherwise healthy periods until a later reconnect is refused. Is the raw receive path intentionally excluded from the new retry semantics? If not, it would be useful to cover reconnect -> successful raw frame -> disconnect again and make sure the budget resets without treating an application error event as success.

@marcuswood-oai
marcuswood-oai added this pull request to the merge queue Sep 8, 2026
Merged via the queue into main with commit f1cd7f0 Sep 8, 2026
26 checks passed
@marcuswood-oai
marcuswood-oai deleted the castiron/promotions/pr-84 branch September 8, 2026 20:24
@openai-sdks openai-sdks Bot mentioned this pull request Sep 8, 2026
pull Bot pushed a commit to TheDegenerateDev5150/openai-python.py that referenced this pull request Sep 9, 2026
Automated Release PR
---


##
[3.10.0](openai/openai-python@v3.9.0...v3.10.0)
(2026-09-08)


### Features

* **api:** add GPT Image 2.5 models and image options
([openai#3824](openai#3824))
([5b39c45](openai@5b39c45))
* **api:** add service-account API key expiration fields
([openai#3802](openai#3802))
([f1cd7f0](openai@f1cd7f0))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: openai-sdks[bot] <284451331+openai-sdks[bot]@users.noreply.github.com>
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.

3 participants