Skip to content

feat(api): Add expiration controls for service account keys - #3825

Open
apcha-oai wants to merge 1 commit into
mainfrom
castiron/promotions/pr-93
Open

feat(api): Add expiration controls for service account keys#3825
apcha-oai wants to merge 1 commit into
mainfrom
castiron/promotions/pr-93

Conversation

@apcha-oai

Copy link
Copy Markdown
Contributor

Summary

Allow project service accounts to create initial API keys with a configurable lifetime and expose their expiration timestamps. Clarify related API behavior and refresh inline documentation links.

Changes

  • Add the optional expires_in_seconds parameter to synchronous and asynchronous service account creation and its request type.
  • Document that key lifetimes may be required or limited by policy and cannot be set with create_service_account_only.
  • Add expires_at expiration metadata to project API key and service account creation response types.
  • Clarify that transcription prompts are unsupported with gpt-4o-transcribe-diarize.
  • Clarify that incoming call webhook SIP headers exclude authorization headers, preserve repetitions and ordering, and must be treated as untrusted metadata.
  • Point SDK resource and type documentation to the current API guides and references.

Castiron-Internal-PR: openai/openai-python-internal#93
Castiron-Source-SHA: 9c43ef94671d731e89ee97a28a600fa31161a569
Castiron-Public-Base-SHA: 8011140
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Castiron custom code

✅ No new custom-code files detected.

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

Compared 8011140bbeb7c61d4971dae3. Generated baselines verified.

File Result Current custom patch
src/openai/resources/audio/transcriptions.py Generated baseline changed +144 / −50
src/openai/resources/audio/translations.py Generated baseline changed +143 / −39
src/openai/resources/beta/responses/responses.py Generated baseline changed +12 / −11
src/openai/resources/beta/threads/runs/runs.py Generated baseline changed +1290 / −181
src/openai/resources/beta/threads/threads.py Generated baseline changed +390 / −7
src/openai/resources/chat/completions/completions.py Generated baseline changed +600 / −1
src/openai/resources/embeddings.py Generated baseline changed +27 / −21
src/openai/resources/files.py Generated baseline changed +26 / −0
src/openai/resources/realtime/realtime.py Generated baseline changed +65 / −32
src/openai/resources/responses/responses.py Generated baseline changed +851 / −18
src/openai/resources/uploads/uploads.py Generated baseline changed +221 / −0
src/openai/resources/vector_stores/file_batches.py Generated baseline changed +242 / −3
src/openai/resources/vector_stores/files.py Generated baseline changed +179 / −1
src/openai/types/responses/response.py Generated baseline changed +15 / −0
src/openai/types/responses/response_function_web_search.py Generated baseline changed +3 / −3
src/openai/types/responses/response_function_web_search_param.py Generated baseline changed +3 / −3
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
src/openai/types/responses/tool.py Generated baseline changed +5 / −0
src/openai/types/responses/tool_param.py Generated baseline changed +9 / −0
16 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/beta/beta.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/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 34301302891 --repo openai/openai-python \
  --name castiron-custom-code-34301302891-1 --dir /tmp/castiron-custom-code-34301302891-1
git apply --stat /tmp/castiron-custom-code-34301302891-1/custom-code.patch
cat /tmp/castiron-custom-code-34301302891-1/custom-code.patch

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

git fetch --no-tags origin 8011140bbeb771d56425602950875bf87beae39e c61d4971dae3d381219ccd7888de067f0e837e1b
python3 scripts/castiron/custom_code_report.py report \
  --base 8011140bbeb771d56425602950875bf87beae39e \
  --head c61d4971dae3d381219ccd7888de067f0e837e1b --fetch --require-head-hash --public \
  --out /tmp/castiron-custom-code-c61d4971dae3
cat /tmp/castiron-custom-code-c61d4971dae3/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

@apcha-oai
apcha-oai marked this pull request as ready for review September 9, 2026 01:57
@apcha-oai
apcha-oai requested a review from a team as a code owner September 9, 2026 01:57
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 9, 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-09T02:00:17.590414Z c61d497 Draft marked ready
🔒 Security Review Completed 2026-09-09T02:03:25.688196Z c61d497 Draft marked ready
ℹ️ 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 9, 2026

Copy link
Copy Markdown
Contributor

OkTest Summary

236/236 SDK tests passed in 9.112s for Python SDK PR #3825.

Test results — 42 files
Test Result Time
tests/chat-completions-complex-body.test.ts ✅ Passed 130ms
tests/chat-completions-create.test.ts ✅ Passed 194ms
tests/chat-completions-stream.test.ts ✅ Passed 116ms
tests/files-content-binary.test.ts ✅ Passed 169ms
tests/files-create-multipart.test.ts ✅ Passed 172ms
tests/files-list-pagination.test.ts ✅ Passed 119ms
tests/initialize-config.test.ts ✅ Passed 121ms
tests/instance-isolation.test.ts ✅ Passed 146ms
tests/models-list.test.ts ✅ Passed 120ms
tests/responses-background-lifecycle.test.ts ✅ Passed 154ms
tests/responses-body-method-errors.test.ts ✅ Passed 247ms
tests/responses-cancel-timeout.test.ts ✅ Passed 213ms
tests/responses-cancel.test.ts ✅ Passed 149ms
tests/responses-compact-retries.test.ts ✅ Passed 265ms
tests/responses-compact.test.ts ✅ Passed 214ms
tests/responses-create-advanced-stream.test.ts ✅ Passed 223ms
tests/responses-create-advanced.test.ts ✅ Passed 144ms
tests/responses-create-disconnect.test.ts ✅ Passed 1.072s
tests/responses-create-errors.test.ts ✅ Passed 204ms
tests/responses-create-malformed-api-responses.test.ts ✅ Passed 82ms
tests/responses-create-retries.test.ts ✅ Passed 180ms
tests/responses-create-stream-failures.test.ts ✅ Passed 93ms
tests/responses-create-stream-timeout.test.ts ✅ Passed 176ms
tests/responses-create-stream-wire.test.ts ✅ Passed 2.98s
tests/responses-create-stream.test.ts ✅ Passed 106ms
tests/responses-create-terminal-states.test.ts ✅ Passed 187ms
tests/responses-create-timeout.test.ts ✅ Passed 211ms
tests/responses-create.test.ts ✅ Passed 411ms
tests/responses-delete.test.ts ✅ Passed 225ms
tests/responses-input-items-errors.test.ts ✅ Passed 273ms
tests/responses-input-items-list.test.ts ✅ Passed 257ms
tests/responses-input-items-options.test.ts ✅ Passed 192ms
tests/responses-input-tokens-count-timeout.test.ts ✅ Passed 223ms
tests/responses-input-tokens-count.test.ts ✅ Passed 181ms
tests/responses-malformed-inputs.test.ts ✅ Passed 2.166s
tests/responses-not-found-errors.test.ts ✅ Passed 282ms
tests/responses-parse.test.ts ✅ Passed 282ms
tests/responses-retrieve-retries.test.ts ✅ Passed 206ms
tests/responses-retrieve.test.ts ✅ Passed 150ms
tests/responses-stored-method-errors.test.ts ✅ Passed 413ms
tests/retry-behavior.test.ts ✅ Passed 3.179s
tests/sdk-error-shape.test.ts ✅ Passed 177ms

View OkTest run #34301239972

SDK merge (62047a06f18f) · head (c61d4971dae3) · base (8011140bbeb7) · 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: c61d4971da

ℹ️ 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".

project_id="project_id",
name="name",
create_service_account_only=True,
expires_in_seconds=1,

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 Test expiration with API-key creation enabled

This success-path test combines expires_in_seconds with create_service_account_only=True, although the new parameter documentation explicitly says a non-null expiration cannot be used in that mode because no initial API key is created. A backend-aware contract test would reject this request, and the current test therefore does not demonstrate that expiration works on a successful service-account creation; use False (or omit the flag) here and in the asynchronous copy.

Useful? React with 👍 / 👎.

@markstuart-oai markstuart-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed the expiration request/response contracts, sync/async serialization, generated schema changes, and documentation refresh. The implementation extends the existing request/model paths without adding special-case runtime logic. Offline expiration probes and all 56 transform tests passed. One low-priority correction below keeps the generated success fixture consistent with the documented API contract.

project_id="project_id",
name="name",
create_service_account_only=True,
expires_in_seconds=1,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P3] Use a valid key-creation combination in the expiration fixture

expires_in_seconds=1 is combined with create_service_account_only=True, but that mode creates no key and the documented contract rejects a non-null expiration. Please set create_service_account_only=False (or omit it) in this test and the asynchronous copy at line 298. These are generated SDK smoke tests rather than backend contract tests, so this does not indicate a shipped serialization defect, but their success fixtures should still represent valid requests.

@jbeckwith-oai jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Two in-scope blockers remain on this exact head. The new service-account test sends expires_in_seconds together with create_service_account_only=True even though the documented contract forbids that combination, so it does not exercise a successful expiring-key request (see the existing inline thread). Also, the shared moderation-model documentation now labels a link as “available models” but points it back to the moderation guide in api_reference/openapi.transformed.yml; that link should target the models documentation. Please correct the source and regenerate.

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