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

# Use Codex with FriendliAI

> Configure Codex CLI to use FriendliAI for fast, cost-efficient, and reliable open-source model inference.

export const AgentSteps = ({agentName, agentInstallUrl, agentPromptPageName, agentPromptUrl, children}) => <Steps>
    <Step title={`Install ${agentName}`}>
      <p>If you haven't already, <a href={agentInstallUrl}>install {agentName}</a>.</p>
    </Step>

    <Step title="Get a FriendliAI API Key">
      <p>If you need a new API key, <a href="/docs/examples/agents/overview#create-an-api-key">create one.</a></p>
    </Step>

    <Step title={`Set Up ${agentName}`}>
      {children}
    </Step>

    <Step title={`Send a Prompt to ${agentName}`}>
      <p>Open your agent and send a prompt. For example, use the following prompt:</p>

      <Prompt description="Use a FriendliAI model to explore your codebase." icon="robot">
        What can you tell me about this codebase?
      </Prompt>

      <p>To learn more, see <a href={agentPromptUrl}>{agentName} Docs {">"} {agentPromptPageName}</a>.</p>
    </Step>

  </Steps>;

export const AgentIntro = ({agentName, agentMarketingUrl}) => <>
    <p>Set up <a href={agentMarketingUrl}>{agentName}</a> to connect to FriendliAI. Once you complete these steps, your agent will send requests to FriendliAI.</p>

    <p>To get started, complete the following steps:</p>

  </>;

<AgentIntro agentName="Codex" agentMarketingUrl="https://openai.com/codex" />

<AgentSteps agentName="Codex" agentInstallUrl="https://learn.chatgpt.com/docs/codex/cli#getting-started" agentPromptPageName="Quickstart" agentPromptUrl="https://learn.chatgpt.com/docs/codex/cli#getting-started">
  1. Open your `~/.codex/config.toml` file.

  2. Add the following to the start of the file:

     ```toml highlight={1,7} theme={null}
     model = "<FRIENDLIAI_MODEL_ID>"
     model_provider = "friendliai"

     [model_providers.friendliai]
     name = "FriendliAI"
     base_url = "https://api.friendli.ai/serverless/v1"
     experimental_bearer_token = "<FRIENDLIAI_API_KEY>"
     ```

     Replace the following placeholders:

     * `<FRIENDLIAI_API_KEY>`: Your FriendliAI API key.
     * `<FRIENDLIAI_MODEL_ID>`: The FriendliAI model ID. For example, `zai-org/GLM-5.2`.

  3. Save your file.

  To learn more, see [Codex Docs > Advanced configuration](https://learn.chatgpt.com/docs/config-file/config-advanced).
</AgentSteps>
