### Run Quickstart Constructor Examples Source: https://github.com/openai/codex/blob/main/sdk/python/examples/README.md Execute the recommended quickstart examples to perform a sanity check of the SDK installation. ```bash python examples/01_quickstart_constructor/sync.py ``` ```bash python examples/01_quickstart_constructor/async.py ``` -------------------------------- ### Quickstart Example Source: https://github.com/openai/codex/blob/main/sdk/python/README.md Demonstrates how to start a Codex thread and run a turn using existing authentication. ```python from openai_codex import Codex with Codex() as codex: thread = codex.thread_start() result = thread.run("Explain this repository in three bullets.") print(result.final_response) ``` -------------------------------- ### Quickstart: Build, Serve, and Interact with Codex App Server Source: https://github.com/openai/codex/blob/main/codex-rs/app-server-test-client/README.md Use these commands to build the debug Codex binary, start the websocket app-server in the background, and then interact with it, for example, by listing models. ```bash # 1) Build debug codex binary cargo build -p codex-cli --bin codex # 2) Start websocket app-server in background cargo run -p codex-app-server-test-client -- \ --codex-bin ./target/debug/codex \ serve --listen ws://127.0.0.1:4222 --kill # 3) Call app-server (defaults to ws://127.0.0.1:4222) cargo run -p codex-app-server-test-client -- model-list ``` -------------------------------- ### windowsSandbox/setupStart Source: https://github.com/openai/codex/blob/main/codex-rs/app-server/README.md Start Windows sandbox setup for the selected mode (`elevated` or `unelevated`). It accepts an optional absolute `cwd` to target setup for a specific workspace, returns `{ started: true }` immediately, and later emits `windowsSandbox/setupCompleted`. ```APIDOC ## windowsSandbox/setupStart ### Description Start Windows sandbox setup for the selected mode (`elevated` or `unelevated`); accepts an optional absolute `cwd` to target setup for a specific workspace, returns `{ started: true }` immediately, and later emits `windowsSandbox/setupCompleted`. ### Parameters - **mode** (string) - Required - The setup mode, either `elevated` or `unelevated`. - **cwd** (string) - Optional - An absolute current working directory to target setup for a specific workspace. ### Response #### Success Response (200) Returns an object indicating that setup has started. - **started** (boolean) - `true` if setup has started. #### Response Example { "started": true } ``` -------------------------------- ### Install Development Dependencies and Activate Virtual Environment Source: https://github.com/openai/codex/blob/main/sdk/python/examples/README.md For contributors running examples from a checkout, install development dependencies using `uv sync` and activate the virtual environment. ```bash uv sync --group dev source .venv/bin/activate ``` -------------------------------- ### Run Python SDK Examples Source: https://github.com/openai/codex/blob/main/sdk/python/examples/README.md Execute synchronous or asynchronous examples from the `sdk/python` directory by specifying the example folder. ```bash python examples//sync.py ``` ```bash python examples//async.py ``` -------------------------------- ### Examples: init_skill.py Source: https://github.com/openai/codex/blob/main/codex-rs/skills/src/assets/samples/skill-creator/SKILL.md Practical examples demonstrating how to use init_skill.py with different options. ```bash scripts/init_skill.py my-skill --path "${CODEX_HOME:-$HOME/.codex}/skills" ``` ```bash scripts/init_skill.py my-skill --path "${CODEX_HOME:-$HOME/.codex}/skills" --resources scripts,references ``` ```bash scripts/init_skill.py my-skill --path ~/work/skills --resources scripts --examples ``` -------------------------------- ### Full example Source: https://github.com/openai/codex/blob/main/codex-rs/skills/src/assets/samples/skill-creator/references/openai_yaml.md A complete example of the `openai.yaml` configuration file, showing various interface, dependency, and policy settings. ```yaml interface: display_name: "Optional user-facing name" short_description: "Optional user-facing description" icon_small: "./assets/small-400px.png" icon_large: "./assets/large-logo.svg" brand_color: "#3B82F6" default_prompt: "Optional surrounding prompt to use the skill with" dependencies: tools: - type: "mcp" value: "github" description: "GitHub MCP server" transport: "streamable_http" url: "https://api.githubcopilot.com/mcp/" policy: allow_implicit_invocation: true ``` -------------------------------- ### Installing `cargo-insta` Source: https://github.com/openai/codex/blob/main/AGENTS.md Install the `cargo-insta` tool for managing snapshot tests. ```bash cargo install --locked cargo-insta ``` -------------------------------- ### Start a turn (invoke a skill) Source: https://github.com/openai/codex/blob/main/codex-rs/app-server/README.md This example shows how to explicitly invoke a skill within a turn by including its name in the text input and providing a corresponding skill input item. This triggers the skill's execution. ```json { "method": "turn/start", "id": 33, "params": { "threadId": "thr_123", "input": [ { "type": "text", "text": "$skill-creator Add a new skill for triaging flaky CI and include step-by-step usage." }, { "type": "skill", "name": "skill-creator", "path": "/Users/me/.codex/skills/skill-creator/SKILL.md" } ] } } { "id": 33, "result": { "turn": { "id": "turn_457", "status": "inProgress", "items": [], "error": null } } } ``` -------------------------------- ### Install skills from GitHub by path Source: https://github.com/openai/codex/blob/main/codex-rs/skills/src/assets/samples/skill-installer/SKILL.md Installs one or more skills from a specified GitHub repository using their relative paths. ```bash scripts/install-skill-from-github.py --repo / --path [ ...] ``` -------------------------------- ### Basic OpenAI Codex Thread Interaction Example Source: https://github.com/openai/codex/blob/main/sdk/python/docs/api-reference.md This example demonstrates how to initialize the Codex client, start a new thread with a specified model and configuration, run a prompt, and print the final response. ```python from openai_codex import Codex with Codex() as codex: thread = codex.thread_start(model="gpt-5.4", config={"model_reasoning_effort": "high"}) result = thread.run("Say hello in one sentence.") print(result.final_response) ``` -------------------------------- ### Install an experimental skill from openai/skills Source: https://github.com/openai/codex/blob/main/codex-rs/skills/src/assets/samples/skill-installer/SKILL.md Installs a specific experimental skill from the openai/skills repository. ```bash scripts/install-skill-from-github.py --repo openai/skills --path skills/.experimental/ ``` -------------------------------- ### Game assets example: UI icon Source: https://github.com/openai/codex/blob/main/codex-rs/skills/src/assets/samples/imagegen/references/sample-prompts.md Example prompt for generating a game UI icon. ```text Use case: stylized-concept Asset type: game UI icon Primary request: round shield icon with a subtle rune pattern Style/medium: painted game UI icon Composition/framing: centered icon; generous padding; clear silhouette Constraints: no text; no background scene elements; no logos or trademarks; no watermark ``` -------------------------------- ### Install a skill from a GitHub URL Source: https://github.com/openai/codex/blob/main/codex-rs/skills/src/assets/samples/skill-installer/SKILL.md Installs a skill directly from its full GitHub URL, including the branch reference and path. ```bash scripts/install-skill-from-github.py --url https://github.com///tree// ``` -------------------------------- ### Game assets example: tileable texture Source: https://github.com/openai/codex/blob/main/codex-rs/skills/src/assets/samples/imagegen/references/sample-prompts.md Example prompt for generating a tileable game texture. ```text Use case: stylized-concept Asset type: tileable game texture Primary request: worn sandstone blocks Style/medium: seamless tileable texture; PBR-ish look Scene/backdrop: neutral lighting reference only Constraints: seamless edges; no obvious focal elements; no text; no logos or trademarks; no watermark ``` -------------------------------- ### Wireframe example: pricing page Source: https://github.com/openai/codex/blob/main/codex-rs/skills/src/assets/samples/imagegen/references/sample-prompts.md Example prompt for generating a pricing page wireframe. ```text Use case: ui-mockup Asset type: website wireframe Primary request: pricing page layout with comparison table Style/medium: low-fi grayscale wireframe Subject: header; plan toggle; 3 pricing cards; comparison table; FAQ accordion; footer Composition/framing: desktop or tablet layout Constraints: label key areas; no color; no logos; no real photos; no watermark ``` -------------------------------- ### Wireframe example: mobile onboarding flow Source: https://github.com/openai/codex/blob/main/codex-rs/skills/src/assets/samples/imagegen/references/sample-prompts.md Example prompt for generating a mobile onboarding flow wireframe. ```text Use case: ui-mockup Asset type: mobile onboarding wireframe Primary request: three-screen mobile onboarding flow Style/medium: low-fi grayscale wireframe Subject: screen 1 headline and CTA; screen 2 feature bullets; screen 3 form fields and CTA Composition/framing: portrait mobile layout Constraints: label screens and blocks; no color; no logos; no real photos; no watermark ``` -------------------------------- ### Wireframe example: homepage (desktop) Source: https://github.com/openai/codex/blob/main/codex-rs/skills/src/assets/samples/imagegen/references/sample-prompts.md Example prompt for generating a desktop homepage wireframe. ```text Use case: ui-mockup Asset type: website wireframe Primary request: SaaS homepage layout with clear hierarchy Style/medium: low-fi grayscale wireframe Subject: top nav; hero with headline and CTA; three feature cards; testimonial strip; pricing preview; footer Composition/framing: landscape desktop layout Constraints: label major blocks; no color; no logos; no real photos; no watermark ``` -------------------------------- ### Logo example: abstract symbol mark Source: https://github.com/openai/codex/blob/main/codex-rs/skills/src/assets/samples/imagegen/references/sample-prompts.md Example prompt for generating an abstract symbol logo. ```text Use case: logo-brand Asset type: logo concept Primary request: geometric leaf symbol suggesting sustainability and growth Style/medium: vector logo mark; flat colors; minimal Composition/framing: centered mark; clear silhouette Color palette: deep green and off-white Constraints: no text unless requested; no gradients; no mockups; no 3D; no watermark ``` -------------------------------- ### Outcome-first prompt example Source: https://github.com/openai/codex/blob/main/codex-rs/skills/src/assets/samples/openai-docs/references/prompting-guide.md An example of defining the target outcome, success criteria, and constraints for GPT-5.5, allowing the model to choose the path. ```text Resolve the customer's issue end to end. Success means: - the eligibility decision is made from the available policy and account data - any allowed action is completed before responding - the final answer includes completed_actions, customer_message, and blockers - if evidence is missing, ask for the smallest missing field ``` -------------------------------- ### Quickstart Source: https://github.com/openai/codex/blob/main/sdk/typescript/README.md Initialize Codex and start a new thread to diagnose a test failure. ```typescript import { Codex } from "@openai/codex-sdk"; const codex = new Codex(); const thread = codex.startThread(); const turn = await thread.run("Diagnose the test failure and propose a fix"); console.log(turn.finalResponse); console.log(turn.items); ``` -------------------------------- ### Start a Process on Exec-Server (JSON) Source: https://github.com/openai/codex/blob/main/codex-rs/exec-server/README.md Starts a new process with specified arguments, working directory, environment, and TTY settings, then receives initial output. ```json {"id":2,"method":"process/start","params":{"processId":"proc-1","argv":["bash","-lc","printf 'ready\n'; while IFS= read -r line; do printf 'echo:%s\n' \"$line\"; done"],"cwd":"file:///tmp","env":{"PATH":"/usr/bin:/bin"},"tty":true,"pipeStdin":false,"arg0":null}} {"id":2,"result":{"processId":"proc-1"}} {"method":"process/output","params":{"processId":"proc-1","seq":1,"stream":"stdout","chunk":"cmVhZHkK"}} ``` -------------------------------- ### turn/start (Invoke a Plugin) Source: https://github.com/openai/codex/blob/main/codex-rs/app-server/README.md Invoke a plugin by including a UI mention token such as `@sample` in the text input and adding a `mention` input item with the exact `plugin://@` path returned by `plugin/installed` or `plugin/list`. ```APIDOC ## RPC Method: turn/start (Invoke a Plugin) ### Description Invoke a plugin by including a UI mention token such as `@sample` in the text input and adding a `mention` input item with the exact `plugin://@` path returned by `plugin/installed` or `plugin/list`. ### RPC Method Name turn/start ### Parameters #### Request Body (params) - **id** (number) - Required - A unique request identifier. - **method** (string) - Required - The RPC method name, "turn/start". - **params** (object) - Required - Parameters for the method. - **threadId** (string) - Required - The ID of the thread. - **input** (array of objects) - Required - Input items for the turn. - **type** (string) - Required - Type of input, e.g., "text", "mention". - **text** (string) - Optional - For "text" type, the user's input. - **name** (string) - Optional - For "mention" type, the name of the plugin. - **path** (string) - Optional - For "mention" type, the plugin path in `plugin://@` form. ### Request Example ```json { "method": "turn/start", "id": 35, "params": { "threadId": "thr_123", "input": [ { "type": "text", "text": "@sample Summarize the latest updates." }, { "type": "mention", "name": "Sample Plugin", "path": "plugin://sample@test" } ] } } ``` ### Response #### Success Response (200 equivalent) - **id** (number) - The request identifier matching the request. - **result** (object) - The result of the operation. - **turn** (object) - Details about the started turn. - **id** (string) - The ID of the turn. - **status** (string) - The status of the turn (e.g., "inProgress"). - **items** (array) - List of items associated with the turn. - **error** (null/object) - Error details if any. #### Response Example ```json { "id": 35, "result": { "turn": { "id": "turn_459", "status": "inProgress", "items": [], "error": null } } } ``` ``` -------------------------------- ### Avoid unnecessary absolute rules Source: https://github.com/openai/codex/blob/main/codex-rs/skills/src/assets/samples/openai-docs/references/prompting-guide.md An example of an instruction style to avoid, which uses strict, step-by-step commands instead of outcome-first definitions. ```text First inspect A, then inspect B, then compare every field, then think through all possible exceptions, then decide which tool to call, then call the tool, then explain the entire process to the user. ``` -------------------------------- ### Start a New Codex Conversation Thread Source: https://github.com/openai/codex/blob/main/codex-rs/app-server/README.md Initiates a new conversation thread with optional configuration settings. The example shows a request, a successful response, and a subsequent notification. ```json { "method": "thread/start", "id": 10, "params": { "model": "gpt-5.1-codex", "cwd": "/Users/me/project", "approvalPolicy": "never", "sandbox": "workspaceWrite", "selectedCapabilityRoots": [ { "id": "github@openai", "location": { "type": "environment", "environmentId": "workspace", "path": "/opt/cca/plugins/github" } } ], "personality": "friendly", "serviceName": "my_app_server_client", "sessionStartSource": "startup", "dynamicTools": [ { "type": "namespace", "name": "tickets", "description": "Ticket management tools", "tools": [ { "type": "function", "name": "lookup_ticket", "description": "Fetch a ticket by id", "deferLoading": true, "inputSchema": { "type": "object", "properties": { "id": { "type": "string" } }, "required": ["id"] } } ] } ] } } ``` ```json { "id": 10, "result": { "thread": { "id": "thr_123", "preview": "", "modelProvider": "openai", "createdAt": 1730910000 } } } ``` ```json { "method": "thread/started", "params": { "thread": { "…" } } } ``` -------------------------------- ### Install Development Dependencies Source: https://github.com/openai/codex/blob/main/sdk/python/docs/getting-started.md Navigate to the Python SDK directory, synchronize development dependencies using `uv sync`, and activate the virtual environment. ```bash cd sdk/python uv sync --group dev source .venv/bin/activate ``` -------------------------------- ### Prompt for Transparent Images Source: https://github.com/openai/codex/blob/main/codex-rs/skills/src/assets/samples/imagegen/SKILL.md Example prompt text to guide image generation models to create subjects on a chroma-key background suitable for removal. ```text Create the requested subject on a perfectly flat solid #00ff00 chroma-key background for background removal. The background must be one uniform color with no shadows, gradients, texture, reflections, floor plane, or lighting variation. Keep the subject fully separated from the background with crisp edges and generous padding. Do not use #00ff00 anywhere in the subject. No cast shadow, no contact shadow, no reflection, no watermark, and no text unless explicitly requested. ``` -------------------------------- ### Run a new shell reusing the host's /usr Source: https://github.com/openai/codex/blob/main/codex-rs/vendor/bubblewrap/README.md An incomplete example demonstrating how to use `bwrap` to create a new shell environment with a custom root filesystem setup. ```sh bwrap \ --ro-bind /usr /usr \ --symlink usr/lib64 /lib64 \ --proc /proc \ --dev /dev \ --unshare-pid \ --new-session \ bash ``` -------------------------------- ### Choosing Sandbox Access Source: https://github.com/openai/codex/blob/main/sdk/python/docs/faq.md Example of using the `sandbox` keyword for threads and turns to control filesystem access. ```python from openai_codex import Sandbox thread = codex.thread_start(sandbox=Sandbox.workspace_write) result = thread.run("Review only.", sandbox=Sandbox.read_only) ``` -------------------------------- ### Example personality block for a steady task-focused assistant Source: https://github.com/openai/codex/blob/main/codex-rs/skills/src/assets/samples/openai-docs/references/prompting-guide.md A prompt snippet defining the personality and collaboration style for an AI assistant that is approachable, steady, direct, and focused on making progress. ```text # Personality You are a capable collaborator: approachable, steady, and direct. Assume the user is competent and acting in good faith, and respond with patience, respect, and practical helpfulness. Prefer making progress over stopping for clarification when the request is already clear enough to attempt. Use context and reasonable assumptions to move forward. Ask for clarification only when the missing information would materially change the answer or create meaningful risk, and keep any question narrow. Stay concise without becoming curt. Give enough context for the user to understand and trust the answer, then stop. Use examples, comparisons, or simple analogies when they make the point easier to grasp. When correcting the user or disagreeing, be candid but constructive. When an error is pointed out, acknowledge it plainly and focus on fixing it. Match the user's tone within professional bounds. Avoid emojis and profanity by default, unless the user explicitly asks for that style or has clearly established it as appropriate for the conversation. ``` -------------------------------- ### Example personality block for an expressive collaborative assistant Source: https://github.com/openai/codex/blob/main/codex-rs/skills/src/assets/samples/openai-docs/references/prompting-guide.md A prompt snippet defining the personality and collaboration style for an AI assistant that is intelligent, curious, playful, warm, and offers a clear point of view. ```text # Personality Adopt a vivid conversational presence: intelligent, curious, playful when appropriate, and attentive to the user's thinking. Ask good questions when the problem is blurry, then become decisive once there is enough context. Be warm, collaborative, and polished. Conversation should feel easy and alive, but not chatty for its own sake. Offer a real point of view rather than merely mirroring the user, while staying responsive to their goals and constraints. Be thoughtful and grounded when the task calls for synthesis or advice. State a clear recommendation when you have enough context, explain important tradeoffs, and name uncertainty without becoming evasive. ``` -------------------------------- ### Control AsyncCodex Turns with Steer and Interrupt Source: https://github.com/openai/codex/blob/main/sdk/python/notebooks/sdk_walkthrough.ipynb This example showcases how to use `steer` to modify an ongoing turn's behavior and `interrupt` to stop a turn prematurely. It also demonstrates streaming events from a turn to get real-time updates on its progress and final status. ```python # Cell 10: async turn controls (steer + interrupt) import asyncio async def async_stream_demo(): async with AsyncCodex() as codex: thread = await codex.thread_start(model='gpt-5.4', config={'model_reasoning_effort': 'high'}) steer_turn = await thread.turn('Count from 1 to 40 with commas, then one summary sentence.') steer_result = await steer_turn.steer('Keep it brief and stop after 10 numbers.') steer_event_count = 0 steer_completed_status = None steer_deltas = [] async for event in steer_turn.stream(): steer_event_count += 1 if event.method == 'item/agentMessage/delta': steer_deltas.append(event.payload.delta) continue if event.method == 'turn/completed': steer_completed_status = event.payload.turn.status.value if steer_completed_status is None: raise RuntimeError('stream ended without turn/completed') steer_preview = ''.join(steer_deltas).strip() interrupt_turn = await thread.turn('Count from 1 to 200 with commas, then one summary sentence.') interrupt_result = await interrupt_turn.interrupt() interrupt_event_count = 0 interrupt_completed_status = None interrupt_deltas = [] async for event in interrupt_turn.stream(): interrupt_event_count += 1 if event.method == 'item/agentMessage/delta': interrupt_deltas.append(event.payload.delta) continue if event.method == 'turn/completed': interrupt_completed_status = event.payload.turn.status.value if interrupt_completed_status is None: raise RuntimeError('stream ended without turn/completed') interrupt_preview = ''.join(interrupt_deltas).strip() print('steer.result:', steer_result.model_dump(mode='json', by_alias=True)) print('steer.final.status:', steer_completed_status) print('steer.events.count:', steer_event_count) print('steer.assistant.preview:', steer_preview) print('interrupt.result:', interrupt_result.model_dump(mode='json', by_alias=True)) print('interrupt.final.status:', interrupt_completed_status) print('interrupt.events.count:', interrupt_event_count) print('interrupt.assistant.preview:', interrupt_preview) await async_stream_demo() ``` -------------------------------- ### Website assets example: blog header image Source: https://github.com/openai/codex/blob/main/codex-rs/skills/src/assets/samples/imagegen/references/sample-prompts.md Example prompt for generating a photorealistic blog header image of an overhead desk scene. ```plaintext Use case: photorealistic-natural Asset type: blog header image Primary request: overhead desk scene with notebook, pen, and coffee cup Scene/backdrop: warm wooden tabletop Style/medium: photorealistic photo Composition/framing: wide crop with clean room for page copy Lighting/mood: soft morning light Constraints: no text; no logos; no watermark ``` -------------------------------- ### turn/start (Invoke an App) Source: https://github.com/openai/codex/blob/main/codex-rs/app-server/README.md Invoke an app by including `$` in the text input and adding a `mention` input item with the app id in `app://` form. ```APIDOC ## RPC Method: turn/start (Invoke an App) ### Description Invoke an app by including `$` in the text input and adding a `mention` input item with the app id in `app://` form. ### RPC Method Name turn/start ### Parameters #### Request Body (params) - **id** (number) - Required - A unique request identifier. - **method** (string) - Required - The RPC method name, "turn/start". - **params** (object) - Required - Parameters for the method. - **threadId** (string) - Required - The ID of the thread. - **input** (array of objects) - Required - Input items for the turn. - **type** (string) - Required - Type of input, e.g., "text", "mention". - **text** (string) - Optional - For "text" type, the user's input. - **name** (string) - Optional - For "mention" type, the name of the app. - **path** (string) - Optional - For "mention" type, the app ID in `app://` form. ### Request Example ```json { "method": "turn/start", "id": 34, "params": { "threadId": "thr_123", "input": [ { "type": "text", "text": "$demo-app Summarize the latest updates." }, { "type": "mention", "name": "Demo App", "path": "app://demo-app" } ] } } ``` ### Response #### Success Response (200 equivalent) - **id** (number) - The request identifier matching the request. - **result** (object) - The result of the operation. - **turn** (object) - Details about the started turn. - **id** (string) - The ID of the turn. - **status** (string) - The status of the turn (e.g., "inProgress"). - **items** (array) - List of items associated with the turn. - **error** (null/object) - Error details if any. #### Response Example ```json { "id": 34, "result": { "turn": { "id": "turn_458", "status": "inProgress", "items": [], "error": null } } } ``` ``` -------------------------------- ### Install Codex CLI on Windows Source: https://github.com/openai/codex/blob/main/README.md Run this PowerShell command to install Codex CLI on Windows, bypassing execution policy for the installation script. ```powershell powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex" ``` -------------------------------- ### thread/realtime/start Source: https://github.com/openai/codex/blob/main/codex-rs/app-server/README.md Starts an experimental thread-scoped real-time session. This method allows configuration of model output modality, model overrides, startup context inclusion, and various handoff behaviors. ```APIDOC ## Method: thread/realtime/start ### Description Start a thread-scoped realtime session (experimental). This method allows configuration of model output modality, model overrides, startup context inclusion, and various handoff behaviors. ### Parameters - **outputModality** (string) - Required - Choose model output: `"text"` or `"audio"`. - **model** (string) - Optional - Overrides configured realtime selection for this session only. - **version** (string) - Optional - For websocket transport only, overrides configured realtime selection for this session only. - **includeStartupContext** (boolean) - Optional - Pass `false` to omit Codex's generated startup context. - **clientManagedHandoffs** (boolean) - Optional - Pass `true` to disable automatic Codex response delivery. - **codexResponsesAsItems** (boolean) - Optional - Pass `true` to send automatic Codex responses as realtime conversation items instead. - **codexResponseItemPrefix** (string) - Optional - Prepends experiment instructions to those items when `codexResponsesAsItems` is `true`. - **codexResponseHandoffPrefix** (string) - Optional - For V1 sessions, routes automatic Codex commentary through `conversation.handoff.append` with that prefix while item mode is disabled. - **transport** (object) - Optional - Omit for the websocket transport, or pass `{ "type": "webrtc", "sdp": "..." }` to create an AVAS/v1 WebRTC session from a browser-generated SDP offer. ### Returns An empty `{}` object. ### Streams `thread/realtime/*` notifications. The remote answer SDP is emitted as `thread/realtime/sdp` for WebRTC sessions. ``` -------------------------------- ### Installation Source: https://github.com/openai/codex/blob/main/sdk/typescript/README.md Install the Codex SDK using npm. ```bash npm install @openai/codex-sdk ``` -------------------------------- ### Install the package Source: https://github.com/openai/codex/blob/main/codex-rs/responses-api-proxy/npm/README.md Install the codex-responses-api-proxy globally using npm. ```bash npm i -g @openai/codex-responses-api-proxy ``` -------------------------------- ### Install OpenAI Codex Python SDK Source: https://github.com/openai/codex/blob/main/sdk/python/docs/getting-started.md Use pip to install the OpenAI Codex Python SDK. This command installs the latest beta release, including its runtime dependency. ```bash pip install openai-codex ``` -------------------------------- ### thread_start Source: https://github.com/openai/codex/blob/main/sdk/python/docs/api-reference.md Starts a new thread with specified configurations, such as approval mode, instructions, and sandbox environment. ```APIDOC ## thread_start(*, approval_mode=ApprovalMode.auto_review, base_instructions=None, config=None, cwd=None, developer_instructions=None, ephemeral=None, model=None, model_provider=None, personality=None, sandbox: Sandbox | None = None) ### Description Starts a new thread with specified configurations, such as approval mode, instructions, and sandbox environment. ### Signature ```python thread_start(*, approval_mode=ApprovalMode.auto_review, base_instructions=None, config=None, cwd=None, developer_instructions=None, ephemeral=None, model=None, model_provider=None, personality=None, sandbox: Sandbox | None = None) -> Awaitable[AsyncThread] ``` ### Parameters - **approval_mode** (ApprovalMode) - Optional - Default: `ApprovalMode.auto_review`. The mode for approving actions within the thread. - **base_instructions** (str | None) - Optional - Base instructions for the thread. - **config** (ThreadConfig | None) - Optional - Configuration specific to the thread. - **cwd** (str | None) - Optional - The current working directory for the thread's execution environment. - **developer_instructions** (str | None) - Optional - Developer-specific instructions for the thread. - **ephemeral** (bool | None) - Optional - If `True`, the thread is ephemeral and will not be persisted. - **model** (str | None) - Optional - The model to use for the thread. - **model_provider** (str | None) - Optional - The provider of the model. - **personality** (str | None) - Optional - The personality to assign to the thread. - **sandbox** (Sandbox | None) - Optional - The sandbox environment configuration for the thread. ### Returns **Awaitable[AsyncThread]** - An awaitable that resolves to the newly created asynchronous thread object. ``` -------------------------------- ### Start a turn (send user input) Source: https://github.com/openai/codex/blob/main/codex-rs/app-server/README.md This snippet demonstrates how to start a new turn by sending user input, which can be text or images, to a thread. Optional configuration overrides can be applied to customize the turn's behavior. ```json { "method": "turn/start", "id": 30, "params": { "threadId": "thr_123", "clientUserMessageId": "client_msg_123", "input": [ { "type": "text", "text": "Run tests" } ], "cwd": "/Users/me/project", "environments": [ { "environmentId": "local", "cwd": "/Users/me/project" } ], "approvalPolicy": "unlessTrusted", "sandboxPolicy": { "type": "workspaceWrite", "writableRoots": ["/Users/me/project"], "networkAccess": true }, "model": "gpt-5.1-codex", "effort": "medium", "summary": "concise", "personality": "friendly", "outputSchema": { "type": "object", "properties": { "answer": { "type": "string" } }, "required": ["answer"], "additionalProperties": false } } } { "id": 30, "result": { "turn": { "id": "turn_456", "status": "inProgress", "items": [], "error": null } } } ``` -------------------------------- ### Example `marketplace.json` Structure Source: https://github.com/openai/codex/blob/main/codex-rs/skills/src/assets/samples/plugin-creator/references/plugin-json-spec.md This snippet illustrates the basic structure of a `marketplace.json` file, including top-level marketplace details and a single plugin entry with its source, policy, and category. ```json { "name": "openai-curated", "interface": { "displayName": "ChatGPT Official" }, "plugins": [ { "name": "linear", "source": { "source": "local", "path": "./plugins/linear" }, "policy": { "installation": "AVAILABLE", "authentication": "ON_INSTALL" }, "category": "Productivity" } ] } ``` -------------------------------- ### Logo example: monogram mark Source: https://github.com/openai/codex/blob/main/codex-rs/skills/src/assets/samples/imagegen/references/sample-prompts.md Example prompt for generating a monogram logo. ```text Use case: logo-brand Asset type: logo concept Primary request: interlocking monogram of the letters "AV" Style/medium: vector logo mark; flat colors; minimal Composition/framing: centered mark; balanced spacing Color palette: black on white Constraints: no gradients; no mockups; no 3D; no watermark ``` -------------------------------- ### Framework/Variant-specific organization example Source: https://github.com/openai/codex/blob/main/codex-rs/skills/src/assets/samples/skill-creator/SKILL.md Example directory structure for organizing skills by framework or variant. ```plaintext cloud-deploy/ ├── SKILL.md (workflow + provider selection) └── references/ ├── aws.md (AWS deployment patterns) ├── gcp.md (GCP deployment patterns) └── azure.md (Azure deployment patterns) ``` -------------------------------- ### Example `apply_patch` Operation Source: https://github.com/openai/codex/blob/main/codex-rs/core/gpt_5_2_prompt.md This snippet demonstrates how to use the `apply_patch` tool to add a new file, update an existing file with a rename, and delete another file. New lines must be prefixed with `+`. ```text *** Begin Patch *** Add File: hello.txt +Hello world *** Update File: src/app.py *** Move to: src/main.py @@ def greet(): -print("Hi") +print("Hello, world!") *** Delete File: obsolete.txt *** End Patch ``` -------------------------------- ### Start Managed Process Response Source: https://github.com/openai/codex/blob/main/codex-rs/exec-server/README.md Confirms the successful start of a managed process, returning its unique identifier. ```json { "processId": "proc-1" } ```