> ## Documentation Index
> Fetch the complete documentation index at: https://docs.inquantum.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenAI Codex

> Use OpenAI Codex CLI and SDK with Planck AI Gateway to log your coding agent interactions.

export const strings = {
  additionalHeadersForSessions: "Planck provides additional headers to help you manage and analyze your sessions.",
  azureOpenAIDocs: `To learn more about the differences between OpenAI and AzureOpenAI, review the <a href="https://learn.microsoft.com/en-us/azure/ai-services/openai/overview">documentation here</a>.`,
  chainOfThoughtPromptingCookbookDescription: "Craft effective prompts, ideal for complex responses requiring multi-step problem solving.",
  chatbotCookbookDescription: "This step-by-step guide covers function calling, response formatting and monitoring with Planck.",
  createPlanckManualLogger: "Create a new PlanckManualLogger instance",
  configureWebSocketConnection: "Configure WebSocket connection",
  environmentTrackingCookbookDescription: "Effortlessly track and manage your environments with Planck across different deployment contexts.",
  exportBaseUrl: tool => `Export your ${tool} base URL`,
  getStartedWithPackage: "To get started, install the @inquantum/planck-helpers package",
  generateKey: "Create an account and generate an API key",
  generateKeyInstructions: `Log into <a href="https://www.inquantum.ai" target="_blank">Planck</a> or create an account. Once you have an account, you can generate an <a href="https://inquantum.ai/developer" target="_blank">API key here</a>.`,
  generateSessionId: "Generate the unique session ID that will be used to track the session.",
  gettingUserRequestsCookbookDescription: "Retrieve user-specific requests to monitor, debug, and track costs for individual users.",
  groupingCallsWithSessions: "Grouping Calls with Planck Sessions",
  handleWebSocketEvents: "Handle WebSocket events",
  planckLoggerAPIReference: `To learn more about the <code>PlanckManualLogger</code> API, see the <a href="/getting-started/integration-method/custom" target="_blank">API Reference here</a>.`,
  howToIntegrate: "How to Integrate",
  howToPromptThinkingModelsCookbookDescription: "Best practices to to effectively prompt thinking models like Deepseek and OpenAI o1-o3 for optimal results.",
  howToUseSessions: "To group related API calls and analyze them collectively, you can use Planck's session tracking features. This is useful for grouping all interactions within a single conversation or user session.",
  includeHeadersInRequests: "Include headers in your requests",
  includeSessionHeaders: "Include the session headers when you make API requests. This way, the session information is attached to each request, allowing Planck to group and analyze them together.",
  installRequiredDependencies: "Install required dependencies",
  installSDK: tool => `Install ${tool}`,
  logYourRequest: "Log your request",
  modifyBasePath: "Modify the base URL path and set up authentication",
  optional: "Optional",
  relatedGuides: "Related documentation",
  replayLlmSessionsCookbookDescription: "Learn how to replay and modify LLM sessions using Planck to optimize your AI agents and improve their performance.",
  sessionManagement: "Session Management",
  setApiKey: "Set up your Planck API key in your .env file",
  setUpToolBaseUrl: tool => `Set up your ${tool} base URL`,
  setUpToolApiKey: tool => `Set up your ${tool} API key as an environment variable`,
  startUsing: tool => `Start using ${tool} with Planck`,
  useTheSDK: tool => `Use the ${tool} SDK`,
  verifyInPlanck: "Verify your requests in Planck",
  verifyInPlanckDescription: tool => `With the above setup, any calls to ${tool} will automatically be logged and monitored by Planck. Review them in your <a href="https://www.inquantum.ai/dashboard" target="_blank">Planck dashboard</a>.`,
  whyUseSessions: "By including the session headers in each request, you have more granular control over session tracking. This approach is especially useful if you want to handle sessions dynamically or manage multiple sessions concurrently.",
  viewRequestsInDashboard: "View requests in the Planck dashboard",
  viewRequestsInDashboardDescription: product => `All your ${product} requests are now visible in your <a href="https://us.inquantum.ai/dashboard" target="_blank">Planck dashboard</a>`,
  modelRegistryDescription: "You can find all 100+ supported models at <a href=\"https://inquantum.ai/models\" target=\"_blank\">inquantum.ai/models</a>."
};

<Info>
  This integration uses the [AI Gateway](/gateway/overview), which provides a unified API for multiple LLM providers. The AI Gateway is currently in beta.
</Info>

## CLI Integration

<Steps>
  <Step title={strings.generateKey}>
    <div dangerouslySetInnerHTML={{ __html: strings.generateKeyInstructions }} />
  </Step>

  <Step title="Configure Codex config file">
    Update your `$CODEX_HOME/.codex/config.toml` file to include the Planck provider configuration:

    <Note>
      `$CODEX_HOME` is typically `~/.codex` on Mac or Linux.
    </Note>

    ```toml config.toml theme={null}
    model_provider = "planck"

    [model_providers.planck]
    name = "Planck"
    base_url = "https://api.inquantum.ai/v1"
    env_key = "PLANCK_API_KEY"
    wire_api = "chat"
    ```
  </Step>

  <Step title="Set your Planck API key">
    Set the `PLANCK_API_KEY` environment variable:

    ```bash theme={null}
    export PLANCK_API_KEY=<your-planck-api-key>
    ```
  </Step>

  <Step title="Run Codex with Planck">
    Use Codex as normal. Your requests will automatically be logged to Planck:

    ```bash theme={null}
    # If you set model_provider in config.toml
    codex "What files are in the current directory?"

    # Or specify the provider explicitly
    codex -c model_provider="planck" "What files are in the current directory?"
    ```
  </Step>

  <Step title={strings.verifyInPlanck}>
    <div dangerouslySetInnerHTML={{ __html: strings.verifyInPlanckDescription("Codex CLI") }} />

    <Tip>
      While you're here, why not <a href="https://github.com/In-Quantum/planck" target="_blank" rel="noreferrer">give us a star on GitHub</a>? It helps us a lot!
    </Tip>
  </Step>
</Steps>

## SDK Integration

<Steps>
  <Step title={strings.generateKey}>
    <div dangerouslySetInnerHTML={{ __html: strings.generateKeyInstructions }} />
  </Step>

  <Step title="Install the Codex SDK">
    ```bash theme={null}
    npm install @openai/codex-sdk
    ```
  </Step>

  <Step title="Configure the SDK with Planck">
    Initialize the Codex SDK with the AI Gateway base URL:

    ```typescript theme={null}
    import { Codex } from "@openai/codex-sdk";

    const codex = new Codex({
      baseUrl: "https://api.inquantum.ai/v1",
      apiKey: process.env.PLANCK_API_KEY,
    });

    const thread = codex.startThread({
      model: "gpt-5" // 100+ models supported
    });
    const turn = await thread.run("What files are in the current directory?");

    console.log(turn.finalResponse);
    console.log(turn.items);
    ```

    <Note>
      The Codex SDK doesn't currently support specifying the wire API, so it will use the Responses API by default. This works with the AI Gateway with limited model and provider support. See the [Responses API documentation](/gateway/concepts/responses-api) for more details.
    </Note>
  </Step>

  <Step title={strings.verifyInPlanck}>
    <div dangerouslySetInnerHTML={{ __html: strings.verifyInPlanckDescription("Codex SDK") }} />
  </Step>
</Steps>

## Additional Features

Once integrated with Planck AI Gateway, you can take advantage of:

* **Unified Observability**: Monitor all your Codex usage alongside other LLM providers
* **Cost Tracking**: Track costs across different models and providers
* **Custom Properties**: Add metadata to your requests for better organization
* **Rate Limiting**: Control usage and prevent abuse

## {strings.relatedGuides}

<CardGroup cols={2}>
  <Card title="AI Gateway Overview" icon="book-open" href="/gateway/overview" iconType="light" vertical>
    Learn more about Planck's AI Gateway and its features
  </Card>

  <Card title="Responses API Support" icon="code" href="/gateway/concepts/responses-api" iconType="light" vertical>
    Use the OpenAI Responses API format through Planck AI Gateway
  </Card>

  <Card title="Provider Routing" icon="route" href="/gateway/provider-routing" iconType="light" vertical>
    Configure automatic routing and fallbacks for reliability
  </Card>

  <Card title="Custom Properties" icon="tag" href="/features/advanced-usage/custom-properties" iconType="light" vertical>
    Add metadata to your requests for better tracking and organization
  </Card>
</CardGroup>
