Skip to main content
A wrapped key only works against the CostHawk proxy. Do not send ch_sk_... directly to Google’s native endpoint.
If you are not sure whether you have a wrapped key or a CostHawk access token, read Wrapped Keys first.

Quick Setup

1

Create a wrapped key

Go to Dashboard → Integrations, click Create API Key, select Google, and paste your Google AI API key.
2

Copy your wrapped key

Copy the ch_sk_... key that CostHawk generates.
3

Update your code

Change the base URL and API key as shown below.

Proxy URL

POST https://costhawk.ai/api/proxy/google
This replaces https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent.

Code Examples

Python

import requests

response = requests.post(
    "https://costhawk.ai/api/proxy/google",
    headers={
        "Content-Type": "application/json",
        "Authorization": "Bearer ch_sk_your_wrapped_key_here",
    },
    json={
        "model": "gemini-2.0-flash",
        "contents": [
            {
                "parts": [
                    {"text": "Hello, Gemini!"}
                ]
            }
        ]
    }
)

data = response.json()
print(data["candidates"][0]["content"]["parts"][0]["text"])

Node.js

const response = await fetch("https://costhawk.ai/api/proxy/google", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer ch_sk_your_wrapped_key_here",
  },
  body: JSON.stringify({
    model: "gemini-2.0-flash",
    contents: [
      {
        parts: [
          { text: "Hello, Gemini!" }
        ]
      }
    ]
  }),
});

const data = await response.json();
console.log(data.candidates[0].content.parts[0].text);

curl

curl -X POST https://costhawk.ai/api/proxy/google \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ch_sk_your_wrapped_key_here" \
  -d '{
    "model": "gemini-2.0-flash",
    "contents": [
      {
        "parts": [
          {"text": "Hello, Gemini!"}
        ]
      }
    ]
  }'
Include the model field in the request body. CostHawk uses it to construct the correct Google API URL (/v1beta/models/{model}:generateContent).

Supported Models

All Google Gemini models work through the proxy, including:
  • gemini-2.0-flash
  • gemini-2.0-pro
  • gemini-1.5-flash
  • gemini-1.5-pro

Supported Endpoint

The proxy supports the generateContent endpoint. Pass the model name in the request body and CostHawk handles the URL routing.