Sign inSign up

christianhkb/sbx-kit-pi-gcp:latest

Multi-platform
Manifest digest

sha256:37c7c00eb1c1762063d932e9531c5aed1b3161c468fb38abbe1151f6188aab88

Last pushed

4 days by christianhkb

Type

Sandbox Kit

Manifest digest

sha256:37c7c00eb1c1762063d932e9531c5aed1b3161c468fb38abbe1151f6188aab88

yaml
schemaVersion: "3"
displayName: Pi GCP Models
description: Adds GCP-hosted models to Pi through Agent Platform AI
version: 0.5.0
kind: mixin
capabilities:
    - type: com.docker.sandbox/lifecycle@1
      config:
        files:
            - content: |
                {
                  "providers": {
                    "gcp-oss-maas": {
                      "baseUrl": "https://aiplatform.googleapis.com/v1/projects/${{ kit.args.project }}/locations/${{ kit.args.location }}/endpoints/openapi",
                      "api": "openai-completions",
                      "apiKey": "$GCP_VERTEX_ACCESS_TOKEN",
                      "authHeader": true,
                      "models": [
                        {
                          "id": "qwen/qwen3-next-80b-a3b-thinking-maas",
                          "displayName": "Qwen 3 Next 80B Thinking (Agent Platform MaaS)",
                          "reasoning": true,
                          "input": ["text"],
                          "contextWindow": 262144,
                          "cost": {"input": 0.15, "output": 1.2, "cacheRead": 0, "cacheWrite": 0}
                        },
                        {
                          "id": "qwen/qwen3-next-80b-a3b-instruct-maas",
                          "displayName": "Qwen 3 Next 80B Instruct (Agent Platform MaaS)",
                          "reasoning": false,
                          "input": ["text"],
                          "contextWindow": 262144,
                          "cost": {"input": 0.15, "output": 1.2, "cacheRead": 0, "cacheWrite": 0}
                        },
                        {
                          "id": "qwen/qwen3-coder-480b-a35b-instruct-maas",
                          "displayName": "Qwen 3 Coder 480B Instruct (Agent Platform MaaS)",
                          "reasoning": false,
                          "input": ["text"],
                          "contextWindow": 258000,
                          "cost": {"input": 0.2, "output": 1.62, "cacheRead": 0.02, "cacheWrite": 0.2}
                        },
                        {
                          "id": "zai-org/glm-5.2-maas",
                          "displayName": "GLM 5.2 (Agent Platform MaaS)",
                          "reasoning": true,
                          "input": ["text"],
                          "contextWindow": 1000000,
                          "cost": {"input": 1.4, "output": 4.4, "cacheRead": 0.14, "cacheWrite": 1.4}
                        },
                        {
                          "id": "zai-org/glm-5-maas",
                          "displayName": "GLM 5 (Agent Platform MaaS)",
                          "reasoning": true,
                          "input": ["text"],
                          "contextWindow": 200000,
                          "cost": {"input": 1, "output": 3.2, "cacheRead": 0.1, "cacheWrite": 1}
                        },
                        {
                          "id": "deepseek-ai/deepseek-v3.2-maas",
                          "displayName": "Deepseek v3.2 (Agent Platform MaaS)",
                          "reasoning": true,
                          "input": ["text"],
                          "contextWindow": 163840,
                          "cost": {"input": 0.56, "output": 1.68, "cacheRead": 0.056, "cacheWrite": 0.56}
                        },
                        {
                          "id": "moonshotai/kimi-k2-thinking-maas",
                          "displayName": "Kimi K2 Thinking (Agent Platform MaaS)",
                          "reasoning": true,
                          "input": ["text"],
                          "contextWindow": 262144,
                          "cost": {"input": 0.6, "output": 2.5, "cacheRead": 0.06, "cacheWrite": 0.6}
                        }
                      ]
                    },
                    "gcp-anthropic": {
                      "baseUrl": "https://aiplatform.googleapis.com/v1/projects/${{ kit.args.project }}/locations/${{ kit.args.location }}/publishers/anthropic",
                      "api": "anthropic-messages",
                      "apiKey": "$GCP_VERTEX_ACCESS_TOKEN",
                      "authHeader": true,
                      "compat": {
                        "supportsStrictTools": false
                      },
                      "models": [
                        {
                          "id": "claude-opus-5-5",
                          "name": "Claude Opus 5.5 (Agent Platform)",
                          "reasoning": true,
                          "thinkingLevelMap": {
                            "off": null,
                            "minimal": null,
                            "low": "low",
                            "medium": "medium",
                            "high": "high",
                            "xhigh": "xhigh",
                            "max": "max"
                          },
                          "input": ["text", "image"],
                          "contextWindow": 1000000,
                          "maxTokens": 128000,
                          "compat": {
                            "supportsMidConvoEffort": true,
                            "supportsMidConvoSystemMessages": true,
                            "supportsMidConvoToolChanges": true,
                            "forceAdaptiveThinking": true,
                            "supportsTemperature": false
                          },
                          "cost": {"input": 4, "output": 20, "cacheRead": 0.2, "cacheWrite": 5}
                        },
                        {
                          "id": "claude-sonnet-5-5",
                          "name": "Claude Sonnet 5.5 (Agent Platform)",
                          "reasoning": true,
                          "thinkingLevelMap": {
                            "off": null,
                            "minimal": null,
                            "low": "low",
                            "medium": "medium",
                            "high": "high",
                            "xhigh": "xhigh",
                            "max": "max"
                          },
                          "input": ["text", "image"],
                          "contextWindow": 1000000,
                          "maxTokens": 128000,
                          "compat": {
                            "supportsMidConvoEffort": true,
                            "supportsMidConvoSystemMessages": true,
                            "supportsMidConvoToolChanges": true,
                            "forceAdaptiveThinking": true,
                            "supportsTemperature": false
                          },
                          "cost": {"input": 2, "output": 10, "cacheRead": 0.1, "cacheWrite": 2.5}
                        },
                        {
                          "id": "claude-haiku-5-5",
                          "name": "Claude Haiku 5.5 (Agent Platform)",
                          "reasoning": true,
                          "thinkingLevelMap": {
                            "minimal": null,
                            "low": "low",
                            "medium": "medium",
                            "high": "high",
                            "xhigh": "xhigh",
                            "max": "max"
                          },
                          "input": ["text", "image"],
                          "contextWindow": 1000000,
                          "maxTokens": 128000,
                          "compat": {
                            "supportsMidConvoEffort": true,
                            "supportsMidConvoSystemMessages": true,
                            "supportsMidConvoToolChanges": true,
                            "forceAdaptiveThinking": true,
                            "supportsTemperature": false
                          },
                          "cost": {
                            "input": 0.1,
                            "output": 0.5,
                            "cacheRead": 0.01,
                            "cacheWrite": 0.125,
                            "tiers": [
                              {"inputTokensAbove": 100000, "input": 0.5, "output": 2.5, "cacheRead": 0.05, "cacheWrite": 0.625}
                            ]
                          }
                        }
                      ]
                    },
                    "google-vertex": {
                      "baseUrl": "https://aiplatform.googleapis.com/v1/projects/${{ kit.args.project }}/locations/${{ kit.args.location }}",
                      "apiKey": "$GCP_VERTEX_ACCESS_TOKEN",
                      "authHeader": true
                    }
                  }
                }
              mode: "0644"
              overwrite: false
              path: /home/agent/.pi/agent/models.json
            - content: |
                {
                  "defaultProvider": "gcp-anthropic",
                  "defaultModel": "claude-haiku-5-5"
                }
              mode: "0644"
              overwrite: false
              path: /home/agent/.pi/agent/settings.json
            - content: |
                import { getApiProvider } from "@earendil-works/pi-ai/compat";
                import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";

                export default function (pi: ExtensionAPI) {
                  const anthropicApi = getApiProvider("anthropic-messages");
                  if (!anthropicApi) return;

                  pi.registerProvider("gcp-anthropic", {
                    api: "anthropic-messages",
                    streamSimple: (model, context, options) => {
                      const baseFetch = options?.fetch ?? globalThis.fetch;
                      const vertexFetch: typeof fetch = async (input, init) => {
                        const rawUrl =
                          typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
                        const url = new URL(rawUrl);
                        const body = typeof init?.body === "string" ? JSON.parse(init.body) : undefined;
                        const modelId = body?.model ?? model.id;
                        if (body) {
                          delete body.model;
                          delete body.fallbacks;
                          body.anthropic_version ??= "vertex-2023-10-16";
                        }
                        const specifier = body?.stream ? "streamRawPredict" : "rawPredict";
                        url.pathname = url.pathname.replace(/\/v1\/messages$/, `/models/${modelId}:${specifier}`);
                        url.searchParams.delete("beta");
                        return baseFetch(url.toString(), {
                          ...init,
                          body: body ? JSON.stringify(body) : init?.body,
                        });
                      };

                      return anthropicApi.streamSimple(model, context, {
                        ...options,
                        apiKey: undefined,
                        fetch: vertexFetch,
                      });
                    },
                  });
                }
              mode: "0644"
              overwrite: false
              path: /home/agent/.pi/agent/extensions/gcp-anthropic.ts
    - type: com.docker.sandbox/network-policy@1
      config:
        runtime:
            allow:
                - aiplatform.googleapis.com
    - type: com.docker.sandbox/credential@1
      config:
        apiKey:
            inject:
                - domain: aiplatform.googleapis.com
                  format: Bearer %s
                  header: Authorization
            name: GCP_VERTEX_ACCESS_TOKEN
            proxyManaged: true
        phase: runtime
        service: gcp-vertex
      description: Google Cloud Agent Platform AI
    - type: com.docker.sandbox/git-identity@1
args:
    location:
        default: global
        description: Agent Platform AI endpoint location
    project:
        required: true
        description: GCP project containing the Agent Platform models