Google Gemini SDK

Use the Google Gemini SDK against this gateway (Python / TypeScript / curl), including cross-vendor calls to GLM, Grok, DeepSeek and more

When to use this: a project already on Google's genai SDK can switch base URL and keep its code unchanged. You can also use the Gemini SDK to call some non-Gemini models (GLM, Grok, DeepSeek, Kimi and others — full scope in "Supported models" below).

Endpoint#

Value
Base URLhttps://jiuye.zsopc.com
Endpoint/v1beta/models/{model}:generateContent (compatible with the Gemini Native API)
Streaming endpoint/v1beta/models/{model}:streamGenerateContent
Authfour positions tried in order: x-api-keyx-goog-api-key?key=Authorization: Bearer. The google-genai SDK sends x-goog-api-key by default, so it works with no changes at all
ProtocolGoogle Generative AI Native (HTTP / SSE streaming)

Prefer a header (x-goog-api-key or x-api-key) over the ?key= query so your API key never lands in URL access logs.

Install#

pip install google-genai     # Python
npm install @google/genai    # TypeScript

Google moved from google-generativeai to the newer google-genai across 2024–2025. This page uses the new SDK.

Python#

Basic call#

from google import genai

client = genai.Client(
    api_key="sk-gpushare-xxx",
    http_options={"base_url": "https://jiuye.zsopc.com"},
)

response = client.models.generate_content(
    model="gemini-2.5-pro",
    contents="Say hello in one word.",
)
print(response.text)

Streaming#

stream = client.models.generate_content_stream(
    model="gemini-2.5-pro",
    contents="Stream a haiku about latency",
)
for chunk in stream:
    print(chunk.text, end="", flush=True)

Calling other vendors (the interesting part)#

The Gemini SDK can reach the cross-vendor models that the Gemini Native endpoint supports — not just Gemini:

# GLM
response = client.models.generate_content(
    model="glm-5.1",
    contents="Hello",
)

# Grok
response = client.models.generate_content(
    model="grok-4-fast-reasoning",
    contents="Hello",
)

# DeepSeek
response = client.models.generate_content(
    model="deepseek-v3.2",
    contents="Hello",
)

# Kimi
response = client.models.generate_content(
    model="kimi-k2.5",
    contents="Hello",
)

Only the models listed in "Supported models" are reachable from this endpoint; anything else returns 503 UNAVAILABLE. Claude models are declared on the channel, but the Gemini → Anthropic conversion has a known upstream defect and may return 500 — call Claude through the Anthropic SDK / Messages endpoint instead.

Multimodal (image input)#

from google.genai import types

with open("photo.jpg", "rb") as f:
    image_bytes = f.read()

response = client.models.generate_content(
    model="gemini-2.5-pro",
    contents=[
        types.Part.from_bytes(data=image_bytes, mime_type="image/jpeg"),
        "Describe this image",
    ],
)
print(response.text)

System instruction#

response = client.models.generate_content(
    model="gemini-3-pro-preview",
    config=types.GenerateContentConfig(
        system_instruction="You are a terse expert. Answer in one sentence.",
    ),
    contents="Why is the sky blue?",
)
print(response.text)

TypeScript#

Basic call#

import { GoogleGenAI } from "@google/genai";

const client = new GoogleGenAI({
  apiKey: process.env.PLATFORM_API_KEY,
  httpOptions: { baseUrl: "https://jiuye.zsopc.com" },
});

const response = await client.models.generateContent({
  model: "gemini-2.5-pro",
  contents: "Say hello in one word.",
});

console.log(response.text);

Streaming#

const stream = await client.models.generateContentStream({
  model: "gemini-2.5-pro",
  contents: "Stream a haiku",
});

for await (const chunk of stream) {
  process.stdout.write(chunk.text ?? "");
}

Calling other vendors#

// GLM
await client.models.generateContent({
  model: "glm-4.7",
  contents: "Hello",
});

// DeepSeek
await client.models.generateContent({
  model: "deepseek-v4-pro",
  contents: "Hello",
});

curl#

Non-streaming#

curl "https://jiuye.zsopc.com/v1beta/models/gemini-2.5-pro:generateContent" \
  -H "x-goog-api-key: $PLATFORM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      {"parts": [{"text": "Say hello in one word."}]}
    ]
  }'

?key=$PLATFORM_API_KEY also works, but the key ends up in URL logs — a header is safer.

Streaming#

curl "https://jiuye.zsopc.com/v1beta/models/gemini-2.5-pro:streamGenerateContent" \
  -H "x-goog-api-key: $PLATFORM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      {"parts": [{"text": "Stream a haiku"}]}
    ]
  }' \
  --no-buffer

Cross-vendor (calling GLM with curl)#

curl "https://jiuye.zsopc.com/v1beta/models/glm-5.1:generateContent" \
  -H "x-goog-api-key: $PLATFORM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      {"parts": [{"text": "Hello"}]}
    ]
  }'

Billing and balance#

  • Every sk-gpushare-* API key draws on the same account balance (a USD wallet), settled on actual token usage. A key has no budget pool of its own — per key you only get access controls: the allowed_models allowlist, an expiry, and enable/disable.
  • Sign-up includes $0.30 of trial credit, enough for every example on this page. Top up at dflop.top/dashboard/billing (Stripe, $1 minimum, same SSO account and shared balance as jiuye.zsopc.com).
  • When the balance runs out every key fails at once (HTTP 402 with status: "RESOURCE_EXHAUSTED"); creating a new key doesn't help, and topping up restores service immediately.

Things to know#

  • The {model} placeholder in the URL is filled from the model argument by the SDK; replace it by hand when using raw curl
  • :generateContent vs :streamGenerateContent — the SDK switches automatically based on generate_content vs generate_content_stream
  • Key auth — the gateway falls back through x-api-keyx-goog-api-key?key=Authorization: Bearer. The google-genai SDK sends x-goog-api-key by default, so nothing needs changing
  • Streaming wire format — the ?alt=sse parameter the SDK puts on streaming URLs is not forwarded upstream. The gateway labels streaming responses content-type: text/event-stream, but the body is forwarded in whatever wire format the serving upstream channel uses by default (SSE frames or a JSON array). If SDK stream parsing fails while curl works, inspect the body with curl --no-buffer to see which format you're getting. Non-streaming calls are unaffected
  • Errors always come back Gemini-style: {"error": {"code": 400, "message": "...", "status": "INVALID_ARGUMENT"}} (where code is the numeric HTTP status)
  • Model scope:
    • Only the models in "Supported models" below are reachable from the Gemini Native endpoint
    • Everything else — including GPT-5.x (gpt-5.4, gpt-5.5), the claude-opus-4-6 line, hunyuan-*, doubao-*, grok-4.3 and so on — returns 503 UNAVAILABLE (no_channel_available) here. Use the OpenAI Chat or Anthropic Messages endpoint instead (see the API reference)
  • Out of balance returns HTTP 402 with a Gemini-style error object: {"error": {"code": 402, "message": "Insufficient balance. Please top up and try again.", "status": "RESOURCE_EXHAUSTED"}}
  • Timeouts — the upstream total ceiling is 180 seconds (streaming is bound by it too, you just get the first token sooner); set your SDK timeout to ≥ 200 seconds

Common errors at a glance#

HTTPstatusMeaningWhat to do
400INVALID_ARGUMENTMalformed body, or the model isn't in this key's allowed_models allowlistCheck the body / the key's allowlist
400NOT_FOUNDThe model id isn't in the platform catalog (message like model `xxx` is not available)Verify the model id
401UNAUTHENTICATEDKey wrong, revoked or expiredCheck the key (re-revealable on its console detail page)
402RESOURCE_EXHAUSTEDAccount balance exhaustedTop up (see "Billing and balance" above)
429RESOURCE_EXHAUSTEDUpstream rate limit passed through (distinguish from 402 by the HTTP status)Back off and retry
503UNAVAILABLEThe model exists but has no channel on the Gemini Native protocol — this is what calling an unlisted model actually looks likeSwitch model, or use the OpenAI Chat / Anthropic Messages endpoint
504DEADLINE_EXCEEDEDUpstream hit the 180-second ceilingShorten the input / switch to streaming / retry

Full cross-protocol error comparison: Error codes

Supported models (Gemini Native endpoint)#

This is the complete set reachable from the Gemini Native endpoint — not the whole catalog (most of the platform's 80+ models use the OpenAI Chat or Anthropic Messages endpoints). Anything not listed returns 503 UNAVAILABLE here:

VendorModels
Googlegemini-3-flash, gemini-3.1-pro-low, gemini-3.1-flash-lite, gemini-3-flash-agent, gemini-3.5-flash-low, gemini-pro-agent
Zhipuglm-4.7, glm-5-turbo, glm-5.1

Claude models aren't supported on this endpoint (there's no Gemini→Anthropic conversion channel, so you get 503 UNAVAILABLE) — call Claude through the Anthropic Messages endpoint.

Full matrix: compatibility matrix · standalone image/video endpoints: Media APIs