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

# Quickstart

> Power Your First AI Agent with ACI.dev

This guide walk you through building an AI agent with function calling capability with ACI.dev

# Sign up to the Platform

* [platform.aci.dev <Icon icon="up-right-from-square" />](https://platform.aci.dev) .
* We'll create a default `project` and default `agent` for you when you first log in to the platform.

# Configure Your First App for Your AI Agent to Use

<Steps>
  <Step title="Configure Github in App Store">
    Navigate to `App Store` and find [GITHUB <Icon icon="up-right-from-square" />](https://platform.aci.dev/apps/GITHUB).
    Then click on `Configure App` button to set up the app for your project.

    <Frame>
      <img src="https://mintcdn.com/aipotheosislabs-60d5bdcb/d29fRbieQpqSnjGv/images/platform/github_configure_app.png?fit=max&auto=format&n=d29fRbieQpqSnjGv&q=85&s=66a1344be1dac0168e6c135fcdc24e2d" alt="GitHub configuration" width="2496" height="892" data-path="images/platform/github_configure_app.png" />
    </Frame>
  </Step>

  <Step title="Link your Github account">
    * Navigate to `App Configurations` and find [GITHUB App Configuration <Icon icon="up-right-from-square" />](https://platform.aci.dev/appconfig/GITHUB). Then click on `Add Account` button to link your Github account.

    <Note>
      `linked account owner id` is the ID of the owner of the linked account. It's up to you to decide which ID to use—it can be the unique end-user ID from your system. Or If you're building an agent for yourself, you can choose any name you prefer. Later, you'll need to provide this `linked account owner id` in your code to execute functions on behalf of the user.
    </Note>

    <Frame>
      <img src="https://mintcdn.com/aipotheosislabs-60d5bdcb/d29fRbieQpqSnjGv/images/platform/github_link_account.png?fit=max&auto=format&n=d29fRbieQpqSnjGv&q=85&s=1db86f84e26c13c0c5bf539a7c57557a" width="2018" height="1484" data-path="images/platform/github_link_account.png" />
    </Frame>

    * Click `Start OAuth2 Flow` button to start the OAuth2 flow and link your Github account under the project.
  </Step>

  <Step title="Allow Your Agents to Access GITHUB">
    <Note>
      * We took an opinionated approach to acommodate a multi-agent architecture. You can create multiple agents within the project, and each agent has its own API key and apps that they are allowed to use.
      * We created a default agent for you when you first log in to the platform.
    </Note>

    Navigate to the project setting page: [Manage Project <Icon icon="up-right-from-square" />](https://platform.aci.dev/project-setting). Then click the `Edit` button under `ALLOWED APPS` column of the agent to allow access to the `GITHUB` app.

    <Frame>
      <img src="https://mintcdn.com/aipotheosislabs-60d5bdcb/d29fRbieQpqSnjGv/images/platform/agent_allowed_apps.png?fit=max&auto=format&n=d29fRbieQpqSnjGv&q=85&s=7d341ee6799412792219c723d30f3b3c" width="1982" height="1396" data-path="images/platform/agent_allowed_apps.png" />
    </Frame>
  </Step>

  <Step title="Grab the API key">
    Each `Agent` is assigned an API key, which you can use to send requests to our platform—either via raw HTTP requests or our SDK. Later, you'll need to include this API key in your code.

    <Frame>
      <img src="https://mintcdn.com/aipotheosislabs-60d5bdcb/d29fRbieQpqSnjGv/images/platform/agent_api_key.png?fit=max&auto=format&n=d29fRbieQpqSnjGv&q=85&s=751c5dbb8f18257a52fb9f5fb3fa2872" width="860" height="176" data-path="images/platform/agent_api_key.png" />
    </Frame>
  </Step>
</Steps>

# Code Example

The ACI Python SDK requires Python 3.10+.
The example below uses `uv` for package installation, but you can use `pip` or any other package manager of your choice.

The full example code is available at the end of this guide.

<Steps>
  <Step title="Initialize repo">
    ```bash bash theme={null}
    uv init
    ```
  </Step>

  <Step title="Install ACI Python SDK">
    * Install the ACI Python SDK

    ```bash bash theme={null}
    uv add aci-sdk
    ```

    * To run the example, you'll also need to install other required packages.

    ```bash bash theme={null}
    uv add openai python-dotenv
    ```
  </Step>

  <Step title="Provide the API key to the SDK">
    You'll need both the ACI API key and the OpenAI API key to run the example in this section. Create a .env file in the root of your project and add the following:

    ```bash .env theme={null}
    ACI_API_KEY=your_aci_api_key
    OPENAI_API_KEY=your_openai_api_key
    ```
  </Step>

  <Step title="Create ACI Client and OpenAI Client">
    ```python python 3.10+ theme={null}
    from dotenv import load_dotenv
    from aci import ACI
    from openai import OpenAI

    load_dotenv()

    aci = ACI()
    openai = OpenAI()
    ```
  </Step>

  <Step title="Get the Function Definition">
    ```python python 3.10+ theme={null}
    github_star_repo_function = aci.functions.get_definition("GITHUB__STAR_REPOSITORY")
    ```
  </Step>

  <Step title="Append the Function Definition to the LLM Request">
    ```python python 3.10+ theme={null}
    response = openai.chat.completions.create(
      model="gpt-4o-2024-08-06",
      messages=[
          {
              "role": "system",
              "content": "You are a helpful assistant with access to a variety of tools.",
          },
          {
              "role": "user",
              "content": "Star the aipotheosis-labs/aci githubrepository for me",
          },
      ],
      tools=[github_star_repo_function],
      tool_choice="required",  # force the model to generate a tool call for demo purposes
    )
    ```
  </Step>

  <Step title="Handle the Tool Call Response and Execute the Function via ACI.dev">
    <Warning>
      Replace `<LINKED_ACCOUNT_OWNER_ID>` with the `linked account owner id` you used when linking your Github account.
    </Warning>

    ```python python 3.10+ {11} theme={null}
    tool_call = (
        response.choices[0].message.tool_calls[0]
        if response.choices[0].message.tool_calls
        else None
    )

    if tool_call:
        result = aci.handle_function_call(
            tool_call.function.name,
            json.loads(tool_call.function.arguments),
            linked_account_owner_id=<LINKED_ACCOUNT_OWNER_ID>
        )
    ```
  </Step>

  <Step title="Full Runnable Code">
    Here is the complete runnable code for the example above, you can copy and paste it into a file and run it.

    <Warning>
      * Remember to provide api keys in the `.env` file.
      * Replace `<LINKED_ACCOUNT_OWNER_ID>` with the `linked account owner id` you used when linking your Github account.
    </Warning>

    ```python python 3.10+ {42} theme={null}
    import json
    from dotenv import load_dotenv
    from openai import OpenAI
    from aci import ACI
    load_dotenv()

    openai = OpenAI()
    aci = ACI()

    def main() -> None:
        # For a list of all supported apps and functions, please go to the platform.aci.dev
        print("Getting function definition for GITHUB__STAR_REPOSITORY")
        github_star_repo_function = aci.functions.get_definition("GITHUB__STAR_REPOSITORY")

        print("Sending request to OpenAI")
        response = openai.chat.completions.create(
            model="gpt-4o-2024-08-06",
            messages=[
                {
                    "role": "system",
                    "content": "You are a helpful assistant with access to a variety of tools.",
                },
                {
                    "role": "user",
                    "content": "Star the aipotheosis-labs/aci github repository for me",
                },
            ],
            tools=[github_star_repo_function],
            tool_choice="required",  # force the model to generate a tool call for demo purposes
        )
        tool_call = (
            response.choices[0].message.tool_calls[0]
            if response.choices[0].message.tool_calls
            else None
        )

        if tool_call:
            print("Handling function call")
            result = aci.handle_function_call(
                tool_call.function.name,
                json.loads(tool_call.function.arguments),
                linked_account_owner_id=<LINKED_ACCOUNT_OWNER_ID>,
            )
            print(result)


    if __name__ == "__main__":
        main()

    ```
  </Step>
</Steps>

# Advanced Usage

For more advanced usage, please refer to the examples in our [ACI Agents Repository <Icon icon="up-right-from-square" />](https://github.com/aipotheosis-labs/aci-agents/tree/main).
