OpenAI API and Codex Documentation

website·Indexed 34 days ago

https://docs.datacoves.com

Documentation for OpenAI models including GPT-4o, o1, and o3 series, as well as the Codex CLI. Covers authentication, model IDs, and developer commands for managing interactive sessions and debugging.

Tokens
26.3K
Snippets
107
Records
216
Agent score
56%

What's inside OpenAI

  1. Overview of Airflow Variables

    Airflow variables are key-value pairs used to store instance-level information that rarely changes, such as API keys or configuration file paths. They support two types: regular values and JSON serialized values. Variables are encrypted with Fernet when stored in the Airflow metastore. To mask sensitive values in the UI and logs, include a substring indicating a sensitive value in the variable name.
  2. Overview of Snowflake Key-Pair Authentication

    Key-pair authentication is a secure alternative to basic username/password authentication in Snowflake. It requires a minimum 2048-bit RSA key pair. The public key is assigned to the Snowflake user, while the private key is stored locally by the client. Snowflake also supports rotating public keys to meet security and governance requirements.
  3. Overview of IAM Roles for Service Accounts (IRSA)

    IAM Roles for Service Accounts (IRSA) allows you to associate an IAM role with a Kubernetes service account. Pods configured to use that service account can then make AWS API requests using the permissions defined in the IAM role. This replaces the need to distribute static AWS credentials to containers or rely on the Amazon EC2 instance profile (node role).

    Key benefits include:

    • Least Privilege: Permissions are scoped to specific service accounts rather than the entire node.
    • Credential Isolation: Pods can only retrieve credentials for their assigned role, preventing access to other Pods' credentials (provided IMDS access is restricted).
    • Auditability: All requests are logged via AWS CloudTrail.

    Constraints: IRSA cannot be used with local clusters for Amazon EKS on AWS Outposts.

  4. Understand AWS Global Infrastructure components for EC2

    Amazon EC2 is hosted across several infrastructure types to provide varying levels of isolation, latency, and proximity:

    • Regions: Separate geographic areas. Each Region is isolated from others to ensure fault tolerance and stability.
    • Availability Zones (AZs): Multiple, isolated locations within a single Region.
    • Local Zones: Extensions of a Region located closer to end users to provide low-latency compute and storage.
    • Wavelength Zones: AWS services deployed at the edge of 5G networks for ultra-low latency to mobile devices.
    • AWS Outposts: Native AWS services and infrastructure deployed on-premises or in third-party colocation spaces.
  5. Retrieve Airflow variables in a DAG

    There are three primary ways to retrieve variables, each with different performance and security trade-offs:

    1. Variable.get(): The most secure method for secrets, but causes performance hits if used in top-level DAG code (hits the metadata DB on every parse).
    2. Jinja Template: The recommended way to avoid performance issues; evaluated only at runtime.
    3. os.getenv(): The fastest method as it avoids DB requests, but less secure for secrets as they may be printed to logs.
    # Method 1: Python API
    from airflow.sdk import Variable
    val = Variable.get('my_var', 'default_value')
    
    # Method 2: Jinja Template (used in operator arguments)
    # {{ var.value.get('my_var', 'default_value') }}
    
    # Method 3: Environment Variable
    import os
    val = os.getenv('AIRFLOW_VAR_my_var', 'default_value')
  6. Manage Codex plugins and marketplaces

    Use codex plugin to install, list, and remove plugins. Use codex plugin marketplace to manage the sources Codex uses to browse and install plugins.

    • Marketplace Sources: codex plugin marketplace add supports GitHub shorthand (owner/repo or owner/repo@ref), Git URLs (HTTP/HTTPS/SSH), and local directories. Use --ref to pin a Git ref and --sparse PATH for sparse checkouts.
    • Automation: Add the --json flag to add, list, upgrade, or remove commands to get machine-readable output.
    # Add a marketplace source
    codex plugin marketplace add owner/repo --ref main
    
    # List plugins in JSON format
    codex plugin list --json
  7. Run the Claude Code CLI within VS Code

    To use the CLI in VS Code, open the integrated terminal (Ctrl+` or Cmd+`) and run claude.

    Key Integration Details:

    • Installation: Requires a standalone CLI install; the extension's bundled version is private and not added to the PATH.
    • External Terminals: If using a terminal outside of VS Code, run /ide inside the CLI to connect it to the editor.
    • Resuming Sessions: To continue a conversation started in the extension within the CLI, run claude --resume to open the conversation picker.
    claude --resume
  8. Authenticate Codex CLI on headless or remote devices

    When browser-based login is unavailable (e.g., remote SSH or blocked localhost callbacks), use one of these three methods:

    1. Device Code Authentication (Beta): The preferred method. Requires enabling device code login in ChatGPT security/workspace settings.
    2. Auth Cache Transfer: Perform codex login on a local machine and copy the resulting ~/.codex/auth.json file to the remote machine.
    3. SSH Port Forwarding: Tunnel the localhost callback server (default port 1455) from the remote host to your local machine.
    # Method 1: Device Code
    codex login --device-auth
    
    # Method 2: Copy auth.json via SSH
    ssh user@remote 'mkdir -p ~/.codex' 
    scp ~/.codex/auth.json user@remote:~/.codex/auth.json
    
    # Method 2: Copy auth.json into Docker
    CONTAINER_HOME=$(docker exec MY_CONTAINER printenv HOME)
    docker exec MY_CONTAINER mkdir -p "$CONTAINER_HOME/.codex"
    docker cp ~/.codex/auth.json MY_CONTAINER:"$CONTAINER_HOME/.codex/auth.json"
    
    # Method 3: Port Forwarding
    ssh -L 1455:localhost:1455 user@remote
    # Then run 'codex login' inside that session
  9. Rotate public keys using RSA_PUBLIC_KEY properties

    If using the RSA_PUBLIC_KEY property instead of named key pairs, you can rotate keys by utilizing the second available slot (RSA_PUBLIC_KEY_2).

    1. Assign the new public key to the unused property (RSA_PUBLIC_KEY or RSA_PUBLIC_KEY_2).
    2. Update your client code to use the new private key.
    3. Remove the old public key using the UNSET command.
    -- 1. Assign new key to the second slot
    ALTER USER example_user SET RSA_PUBLIC_KEY_2='JERUEHtcve...';
    
    -- 3. Remove the old key
    ALTER USER example_user UNSET RSA_PUBLIC_KEY;
  10. Best practices for using Airflow Variables

    To maintain performance and security in Airflow, follow these guidelines:

    • Use variables for runtime-dependent information that changes infrequently.
    • Avoid top-level DAG code: Do not call variables outside of tasks in the DAG file, as this creates a connection to the metastore every time the DAG is parsed.
    • Use Jinja Templates: If a variable is needed in the DAG definition, use Jinja template syntax so it is only rendered during task execution.
    • Choose the right storage:
      • Use Environment Variables for global settings or CI/CD integration.
      • Use Params for DAG-specific or run-specific overrides.
      • Use XComs for passing small pieces of data between tasks within a run.
  11. Send prompts and reference code in Claude Code

    You can ask Claude to explain, debug, or modify code. Claude automatically detects any text you have selected in the editor.

    To explicitly reference a specific file or line range (e.g., @file.ts#5-10) in your prompt, use the following keyboard shortcut while text is selected:

    • Mac: Option+K
    • Windows/Linux: Alt+K
  12. Manage Claude Code agent maps and background tasks

    When subagents are active, an agent count appears at the bottom of the prompt box. Clicking this opens the Agent Map, which displays subagents as a tree showing status, elapsed time, and token count. You can click a subagent to view its prompt, tool calls, or stop it. Background tasks (like shell commands and monitors) are also listed below the agents in this map.