Skip to main content

Model Providers

Google AI Studio (Gemini API)

Call Gemini text models with a Google AI Studio API key through your Verdictan gateway. Your application sends an OpenAI-style Chat Completions request, and the gateway translates it to the Gemini API and translates the reply back.

To use Google Cloud IAM credentials instead of an API key, see Google Vertex AI.

Before you start​

  • A working gateway from the quickstart.
  • A Google AI Studio API key, and one Gemini model ID that the key can use.
  • The gateway startup command, and a separate application token for test requests.

Configure the provider​

Keep provider_type and format as shown. verdictan policy lint uses provider_type to check secret_key_ref.

policy-config.yaml
pack:
  name: google-ai-studio-integration
  version: 1.0.0
  enabled: true
policies:
  chain:
    - prompt-injection
providers:
  targets:
    - id: google-ai-studio-primary
      provider: google-ai-studio
      provider_type: google-ai-studio
      format: google-gemini
      model: "replace-with-gemini-model-id"
      base_url: https://generativelanguage.googleapis.com
      secret_key_ref:
        env: VERDICTAN_GOOGLE_AI_STUDIO_API_KEY

The gateway sends each request to /v1beta/models/{model}:generateContent and puts the key from VERDICTAN_GOOGLE_AI_STUDIO_API_KEY in the x-goog-api-key header.

Start and verify​

You can publish the Google AI Studio target with CLI 0.1.14 or later. Check In sync before the non-streaming request below. That request also checks provider access.

With the quickstart in Docker, follow the container steps instead of steps 1 to 3.

  1. In the gateway terminal, set the key and lint the file:

    export VERDICTAN_GOOGLE_AI_STUDIO_API_KEY="<provider-api-key>"
    verdictan policy lint --file policy-config.yaml
  2. Restart the test gateway with the key in its environment.

  3. Deploy the file to the test agent in Configurations. If that agent already runs pack.version 1.0.0, increase the version first. Then wait for the gateway log line connected read model refresh applied updated config with your version as config_version. Try the change on a test gateway has the steps.

  4. In a second terminal, send a non-streaming request for the configured model:

    export VERDICTAN_CLIENT_TOKEN="<application-token>"
    curl --fail-with-body http://127.0.0.1:41002/v1/chat/completions \
      -H "Authorization: Bearer ${VERDICTAN_CLIENT_TOKEN}" \
      -H "Content-Type: application/json" \
      -d '{"model":"replace-with-gemini-model-id","stream":false,"messages":[{"role":"user","content":"Reply with Hello."}]}'

choices[0].message.content contains the reply, and the request appears in History when capture is on, or in the delivered events.

Supported requests​

RequestSupport
Chat Completions, text, stream: falseYes. Messages and common generation settings are translated to Gemini generateContent.
StreamingNot recommended. Gemini stream frames are not fully translated to the OpenAI stream shape.
MessagesNot tested with this adapter
Tools, image input, Responses, embeddings, response_formatNo

Failure behavior​

ProblemWhat to check
401 from the gatewayThe application token is active, and the key is set on the gateway host.
Provider authentication errorVERDICTAN_GOOGLE_AI_STUDIO_API_KEY is set in the gateway process. Restart the gateway.
policy lint rejects secret_key_refprovider_type: google-ai-studio is present.
Model not foundThe Gemini model ID matches the target, and your key can use it.
Broken output in a streaming clientSend stream: false.
Provider 429 or another upstream errorThe response body and your Gemini API quota. See Error Handling.

Limits​

  • Model names, prices, rate limits, and data terms are in the Gemini API documentation.
  • The translation covers text messages and common generation settings. Other OpenAI request fields can be dropped.
  • A listener on a non-loopback address needs TLS and network controls.

Next steps​