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

# Host AI Agents

You can host AI agents on Upsun using any runtime that supports your preferred
programming language and integrate with various LLM APIs. Upsun provides
container-based deployments that give you control over your application
architecture and dependencies.

## Runtime and language support

Upsun supports multiple runtimes through container-based deployments including
Python, Node.js, PHP, Ruby, Go, Java, and more. For the complete list of
supported runtimes and their versions, see the [runtime types reference](/docs/configure-apps/app-reference/single-runtime-image#type).

Configure your runtime in the [`.upsun/config.yaml`](/docs/core-concepts/yaml/yaml-structure)
file.
The platform builds your application in a container with the specified runtime
and dependencies.

## LLM API integration

You can integrate your AI agent with any LLM API that your chosen runtime supports:

* **OpenAI API**: Use the [official OpenAI client libraries](https://platform.openai.com/docs/libraries)
  for Python, Node.js, and other languages
* **Anthropic Claude API**: Use the [Anthropic client libraries](https://docs.anthropic.com/en/docs/getting-started-with-the-api) for Python,
  Node.js, and other languages
* **Google Gemini**: Use the [Google AI client libraries](https://ai.google.dev/docs)
  for Python, Node.js, and other languages
* **Azure OpenAI**: Use the [Azure OpenAI client libraries](https://learn.microsoft.com/en-us/azure/ai-services/openai/) for Python,
  Node.js, and other languages
* **AWS Bedrock**: Use the [AWS Bedrock client libraries](https://docs.aws.amazon.com/bedrock/) for Python, Node.js, and other languages
* **Other providers**: Integrate with any API that provides HTTP endpoints

Your application code handles the API calls and response processing. Upsun doesn't
restrict which services you can use.

## Environment management

Upsun provides isolated environments for development, testing, and production:

* **Branch-based environments**: Each Git branch creates a separate environment
* **Data isolation**: Each environment has its own services and data
* **Easy cloning**: Clone production data to development environments for testing
* **Environment variables**: Store API keys and configuration securely using
  [variables](/docs/development/variables)

## Tutorials

* **Deploy a RAG-based conversational agent with Chainlit**: Build a Retrieval-Augmented
  Generation agent using Chainlit, llama\_index, and OpenAI, then deploy it on Upsun.
  See the [Chainlit deployment tutorial](https://devcenter.upsun.com/posts/deploying-chainlit-with-rag/).

* **Access Documentation contextually via Context7 + MCP**: Use the Model Context
  Protocol to let AI assistants fetch your Upsun documentation in real-time. See the
  [Context7 MCP article](https://devcenter.upsun.com/posts/context7-mcp/).

* **Use the Upsun API to automate Agent deployment**: Automate deployments, environment
  management, and configuration through the Upsun API. See the
  [API usage guide](https://devcenter.upsun.com/posts/using-the-upsun-api/).

## Configuration example

Here's a basic configuration for a Python AI agent. For more configuration
options, see the [complete application reference](/docs/configure-apps/app-reference/single-runtime-image):

```yaml theme={null}
# .upsun/config.yaml
applications:
  ai-agent:
    source:
      root: "/"
    type: "python:3.11"
    mounts:
      ".data": source: "storage", source_path: "data"
    web:
      commands:
        start: "python agent.py"
      upstream:
        socket_family: tcp
        locations:
          "/": root: "", passthru: true
```

## Application Code

For examples of how to implement AI agents with different frameworks and APIs,
see the [AI and Machine Learning tutorials on DevCenter](https://devcenter.upsun.com/posts/ai?utm_source=docs\&utm_medium=ai-agent\&utm_campaign=tutorials).

## Deploy your Agent

1. Add your code to Git:

   ```bash theme={null}
   git add .
   git commit -m "Add AI agent service"
   ```

2. Set your OpenAI API key as an environment variable using the \[CLI]
   (/cli):

   ```bash theme={null}
   upsun variable:create env:OPENAI_API_KEY --value=<your_key>
   ```

   For more information about setting variables, see \[how to set variables]
   (/docs/development/variables/set-variables).

3. Deploy to Upsun:

   ```bash theme={null}
   upsun push
   ```

Your agent will be available at your Upsun environment URL. The platform handles
the containerization, networking, and scaling automatically. For more deployment
options, see [deploy your project](/docs/core-concepts/build-deploy).

***

## Key benefits

* **Runtime flexibility**: Choose the programming language and version that fits
  your needs
* **Service independence**: Use any LLM API or external service
* **Environment isolation**: Test changes safely in separate environments
* **Automated deployment**: Deploy through Git pushes or API calls
* **Scalability**: The platform handles load balancing and resource allocation

For more information about building and deploying applications, see the
[configure apps](/docs/configure-apps) section.
