Integration guide

How to use GCP Cloud Functions with an OpenAI-compatible endpoint (Python)

GCP Cloud Functions integration guide for Python. Connect to an OpenAI-compatible endpoint with a base URL swap and keep the same request schema.

Updated 2026-01-06

GCP Cloud Functions works with OpenAI-compatible APIs by switching the base URL and API key.

This guide shows a Python example plus a test vector you can run to validate responses.

import os
import requests

payload = {
    "model": "abliterated-model",
    "messages": [{"role": "user", "content": "Respond with: GCP Cloud Functions Python ready."}],
    "temperature": 0.2,
}

resp = requests.post(
    "https://api.abliteration.ai/v1/chat/completions",
    headers={
        "Authorization": f"Bearer {os.getenv('ABLIT_KEY')}",
        "Content-Type": "application/json",
    },
    json=payload,
)

resp.raise_for_status()
print(resp.json()["choices"][0]["message"]["content"])

Configure GCP Cloud Functions

Follow this checklist to point your integration at the OpenAI-compatible endpoint.

OpenAI-compatible payload

Use this request body as a known-good payload before customizing parameters.

{
  "model": "abliterated-model",
  "messages": [
    { "role": "user", "content": "Respond with: GCP Cloud Functions Python ready." }
  ],
  "temperature": 0.2
}

Streaming and tool calling readiness

If you stream responses or send tool definitions, keep the OpenAI-compatible schema and validate against the OpenAPI spec.