> ## 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 Pi with FriendliAI

> Configure Pi 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="/integrate/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="Pi" agentMarketingUrl="https://pi.dev" />

<AgentSteps agentName="Pi" agentInstallUrl="https://pi.dev/docs/latest/quickstart" agentPromptPageName="Using Pi" agentPromptUrl="https://pi.dev/docs/latest/usage">
  1. Open your `~/.pi/agent/models.json` file.

  2. Add the following to the file:

     ```json highlight={6,9,10} theme={null}
     {
       "providers": {
         "friendliai-chat-completions": {
           "baseUrl": "https://api.friendli.ai/serverless/v1",
           "api": "openai-completions",
           "apiKey": "<FRIENDLIAI_API_KEY>",
           "models": [
             {
               "id": "<FRIENDLIAI_MODEL_ID>",
               "reasoning": <FRIENDLIAI_MODEL_REASONING>
             }
           ]
         }
       }
     }
     ```

     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`.
     * `<FRIENDLIAI_MODEL_REASONING>`: Whether the model is a reasoning model. For example, `true` for `zai-org/GLM-5.2`.

  3. Save your file.

  To learn more, see [Pi Docs > Custom Models](https://pi.dev/docs/latest/models).
</AgentSteps>
