---
title: "GCP Examples"
description: "Deploy elizaOS to Google Cloud Functions and Cloud Run"
---

Deploy AI agents to Google Cloud Platform.

## Quick Start

```bash
cd examples/gcp

# Deploy Cloud Function
gcloud functions deploy eliza-chat \
  --runtime nodejs20 \
  --trigger-http \
  --allow-unauthenticated \
  --set-env-vars OPENAI_API_KEY=$OPENAI_API_KEY
```

## Available Implementations

| Language   | Directory        | Runtime    |
| ---------- | ---------------- | ---------- |
| TypeScript | `examples/gcp/`  | Node.js 20 |

## TypeScript Handler

```typescript
import { HttpFunction } from "@google-cloud/functions-framework";
import { AgentRuntime } from "@elizaos/core";
import { openaiPlugin } from "@elizaos/plugin-openai";

let runtime: AgentRuntime | null = null;

export const elizaChat: HttpFunction = async (req, res) => {
  if (!runtime) {
    runtime = new AgentRuntime({
      character: { name: "Eliza", bio: "A helpful AI." },
      plugins: [openaiPlugin],
    });
    await runtime.initialize();
  }

  const { message } = req.body;
  const response = await runtime.useModel("TEXT_LARGE", { prompt: message });

  res.json({ response: String(response) });
};
```

## Testing Locally

```bash
cd examples/gcp
bun install
bun run dev
curl -X POST http://localhost:8080 \
  -H "Content-Type: application/json" \
  -d '{"message": "Hello!"}'
```

## Cloud Run Deployment

The sample `Dockerfile` in `examples/gcp/` builds the TypeScript worker:

```bash
cd examples/gcp
docker build -t gcr.io/PROJECT/eliza-worker-typescript .
docker push gcr.io/PROJECT/eliza-worker-typescript
gcloud run deploy eliza-worker-typescript \
  --image gcr.io/PROJECT/eliza-worker-typescript \
  --set-env-vars OPENAI_API_KEY=$OPENAI_API_KEY
```

## Terraform

Infrastructure as code is available in `examples/gcp/terraform/`:

```hcl
resource "google_cloudfunctions_function" "eliza" {
  name        = "eliza-chat"
  runtime     = "nodejs20"
  entry_point = "elizaChat"

  environment_variables = {
    OPENAI_API_KEY = var.openai_api_key
  }
}
```



