# APIpie (https://www.librechat.ai/docs/configuration/librechat_yaml/ai_endpoints/apipie)

APIpie is an aggregator that exposes models from many providers through a single OpenAI-compatible endpoint.

## Get an API key

Create a key from [apipie.ai/dashboard/profile/api-keys](https://apipie.ai/dashboard/profile/api-keys) and add it to your `.env` file:

```bash filename=".env"
APIPIE_API_KEY=your-api-key
```

## Configuration

Add the endpoint under `endpoints.custom` in your `librechat.yaml`:

```yaml filename="librechat.yaml"
    - name: "APIpie"
      apiKey: "${APIPIE_API_KEY}"
      baseURL: "https://apipie.ai/v1/"
      models:
        default: [
          "gpt-4",
          "gpt-4-turbo",
          "gpt-3.5-turbo",
          "claude-3-opus",
          "claude-3-sonnet",
          "claude-3-haiku",
          "llama-3-70b-instruct",
          "llama-3-8b-instruct",
          "gemini-pro-1.5",
          "gemini-pro",
          "mistral-large",
          "mistral-medium",
          "mistral-small",
          "mistral-tiny",
          "mixtral-8x22b",
          ]
        fetch: false
      titleConvo: true
      titleModel: "claude-3-haiku"
      summarize: false
      summaryModel: "claude-3-haiku"
      dropParams: ["stream"]
      modelDisplayLabel: "APIpie"
```

<Callout type="tip" title="Fetch and order the models" collapsible>
This python script can fetch and order the LLM models for you. The output is saved to `models.txt`, formatted so it is easier to drop into the yaml config.

```py filename="fetch.py"
import json
import requests

def fetch_and_order_models():
    # API endpoint
    url = "https://apipie.ai/models"

    # headers as per request example
    headers = {"Accept": "application/json"}

    # request parameters
    params = {"type": "llm"}

    # make request
    response = requests.get(url, headers=headers, params=params)

    # parse JSON response
    data = response.json()

    # extract an ordered list of unique model IDs
    model_ids = sorted(set([model["id"] for model in data]))

    # write result to a text file
    with open("models.txt", "w") as file:
        json.dump(model_ids, file, indent=2)

# execute the function
if __name__ == "__main__":
    fetch_and_order_models()
```
</Callout>

## Notes

- Automatic model fetching is not supported, so `fetch` is set to `false` and the model list is defined inline. Use the script above to regenerate the list when new models are added.
- Conversation titling results can be inconsistent.
- `dropParams: ["stream"]` removes the `stream` parameter, which is not currently supported.
