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

# Deploy: GCP

> Deploy agents to Google Cloud Run using praisonai deploy

Deploy agents to Google Cloud Run using `praisonai deploy run --type cloud --provider gcp`.

## Quick Start - CLI

<Steps>
  <Step title="Install PraisonAI">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    pip install praisonai
    ```
  </Step>

  <Step title="Set Environment Variables">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    export OPENAI_API_KEY="your-key"
    export GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account.json"
    ```
  </Step>

  <Step title="Initialize GCP Config">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    praisonai deploy init --file agents.yaml --type cloud --provider gcp
    ```
  </Step>

  <Step title="Check Readiness">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    praisonai deploy doctor --provider gcp
    ```
  </Step>

  <Step title="Deploy to GCP">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    praisonai deploy run --file agents.yaml --type cloud --provider gcp
    ```

    **Expected Output:**

    ```
    🚀 Starting deployment...

    ☁️  Deploying to Google Cloud Run
      • Project: your-project-id
      • Region: us-central1
      • Service: praisonai-service

    📦 Building and pushing Docker image...
    🚀 Deploying to Cloud Run...

    ✅ Deployment successful!
    🔗 URL: https://praisonai-service-abc123-uc.a.run.app

    Metadata:
      • provider: gcp
      • project_id: your-project-id
      • region: us-central1
      • service: praisonai-service
    ```
  </Step>

  <Step title="Verify">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    curl https://praisonai-service-abc123-uc.a.run.app/health
    ```
  </Step>
</Steps>

## Quick Start - SDK

<Steps>
  <Step title="Create Deploy Script">
    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    from praisonai.deploy import Deploy, DeployConfig, DeployType, CloudProvider
    from praisonai.deploy.models import CloudConfig

    config = DeployConfig(
        type=DeployType.CLOUD,
        cloud=CloudConfig(
            provider=CloudProvider.GCP,
            region="us-central1",
            service_name="praisonai-service",
            project_id="your-project-id",
            cpu="1",
            memory="512",
            min_instances=0,
            max_instances=10
        )
    )

    deploy = Deploy(config, "agents.yaml")
    result = deploy.deploy()

    print(f"URL: {result.url}")
    ```
  </Step>

  <Step title="Run">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    python deploy_gcp.py
    ```
  </Step>
</Steps>

## agents.yaml with GCP Config

```yaml theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
framework: praisonai
topic: helpful assistant
roles:
  assistant:
    role: Assistant
    goal: Help users with their questions
    backstory: You are a helpful assistant
    tasks:
      help_task:
        description: Answer user questions
        expected_output: Helpful response

deploy:
  type: cloud
  cloud:
    provider: gcp
    region: "us-central1"
    service_name: "praisonai-service"
    project_id: "${GOOGLE_CLOUD_PROJECT}"
    cpu: "1"
    memory: "512"
    min_instances: 0
    max_instances: 10
    env_vars:
      OPENAI_API_KEY: "${OPENAI_API_KEY}"
```

## GCP Cloud Config Options

| Field           | Type   | Default | Description                           |
| --------------- | ------ | ------- | ------------------------------------- |
| `provider`      | string | -       | Must be `gcp`                         |
| `region`        | string | -       | GCP region (e.g., `us-central1`)      |
| `service_name`  | string | -       | Cloud Run service name                |
| `project_id`    | string | -       | GCP project ID                        |
| `cpu`           | string | `1`     | CPU allocation                        |
| `memory`        | string | `512`   | Memory in MB                          |
| `min_instances` | int    | `0`     | Minimum instances (0 = scale to zero) |
| `max_instances` | int    | `10`    | Maximum instances                     |
| `env_vars`      | dict   | `null`  | Environment variables                 |

## Check Deployment Status

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai deploy status --file agents.yaml
```

## Destroy Deployment

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
praisonai deploy destroy --file agents.yaml --yes
```

## Troubleshooting

| Issue             | Fix                                                         |
| ----------------- | ----------------------------------------------------------- |
| GCP credentials   | `gcloud auth login` or set `GOOGLE_APPLICATION_CREDENTIALS` |
| Project not set   | Add `project_id` to agents.yaml                             |
| Permission denied | Check IAM permissions for Cloud Run                         |
| Deploy failed     | Run `praisonai deploy doctor --provider gcp`                |

<Accordion title="Manual GCP CLI Deployment (Optional)">
  These commands are for manual deployment only. Use `praisonai deploy` for automated deployment.

  ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  # Initialize and enable services
  gcloud init
  gcloud services enable run.googleapis.com
  gcloud services enable containerregistry.googleapis.com
  gcloud services enable cloudbuild.googleapis.com

  # Set environment variables
  export OPENAI_MODEL_NAME="gpt-4o"
  export OPENAI_API_KEY="your-api-key"
  export OPENAI_API_BASE="https://api.openai.com/v1"

  # Configure Docker authentication
  yes | gcloud auth configure-docker us-central1-docker.pkg.dev 
  gcloud artifacts repositories create praisonai-repository --repository-format=docker --location=us-central1

  # Build and push Docker image
  PROJECT_ID=$(gcloud config get-value project)
  TAG="latest"
  docker build --platform linux/amd64 -t gcr.io/${PROJECT_ID}/praisonai-app:${TAG} .
  docker tag gcr.io/${PROJECT_ID}/praisonai-app:${TAG} us-central1-docker.pkg.dev/${PROJECT_ID}/praisonai-repository/praisonai-app:${TAG}
  docker push us-central1-docker.pkg.dev/${PROJECT_ID}/praisonai-repository/praisonai-app:${TAG}

  # Deploy to Cloud Run
  gcloud run deploy praisonai-service \
      --image us-central1-docker.pkg.dev/${PROJECT_ID}/praisonai-repository/praisonai-app:${TAG} \
      --platform managed \
      --region us-central1 \
      --allow-unauthenticated \
      --set-env-vars OPENAI_MODEL_NAME=${OPENAI_MODEL_NAME},OPENAI_API_KEY=${OPENAI_API_KEY},OPENAI_API_BASE=${OPENAI_API_BASE}
  ```

  **Validation Commands:**

  ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
  # Verify GCP CLI
  gcloud config get-value project

  # List Cloud Run services
  gcloud run services list

  # Describe service
  gcloud run services describe praisonai-service --region us-central1

  # View logs
  gcloud run services logs read praisonai-service --region us-central1
  ```
</Accordion>

## Related

* [Deploy CLI Overview](./index) - All deploy commands
* [API Deploy](./api) - Deploy as local API server
* [Docker Deploy](./docker) - Deploy to Docker
* [AWS Deploy](./aws) - Deploy to AWS ECS/Fargate
