Skip to main content
HasteKit LLM Gateway supports Google Gemini’s GenerateContent API for text generation, images, tool calling, and reasoning. You can use any Gemini SDK by simply pointing it to HasteKit’s gateway endpoint. This allows you to leverage HasteKit’s features like virtual keys, provider management, and observability while using your existing Gemini code.

Overview

The HasteKit LLM Gateway provides an endpoint at /api/gateway/gemini/v1beta/models/{model} that implements Google Gemini’s GenerateContent API specification. This means you can use any Gemini SDK (Python, JavaScript, Go, etc.) without modifying your code - just change the base URL.

Usage Examples

main.py
import google.generativeai as genai

# Configure to use HasteKit's gateway endpoint
genai.configure(
    api_key="sk-hk-your-virtual-key-here",  # or your Gemini API key
    client_options={
        "api_endpoint": "http://localhost:6060/api/gateway/gemini/v1beta"
    }
)

# Use the GenerateContent API
# Note: Model name includes the action (generateContent)
model = genai.GenerativeModel('gemini-1.5-pro:generateContent')

response = model.generate_content("Hello, how are you?")
print(response.text)

Streaming Support

The gateway supports streaming responses. Use streamGenerateContent as the action in the model name:
streaming.py
import google.generativeai as genai

genai.configure(
    api_key="sk-hk-your-virtual-key-here",
    client_options={
        "api_endpoint": "http://localhost:6060/api/gateway/gemini/v1beta"
    }
)

# Use streamGenerateContent as the action
model = genai.GenerativeModel('gemini-1.5-pro:streamGenerateContent')

response = model.generate_content("Tell me a story.", stream=True)

for chunk in response:
    print(chunk.text, end="", flush=True)

Supported Features

The gateway currently supports the GenerateContent API with:
  • Text generation - Standard text completions
  • Images - Image input and generation
  • Tool calling - Function calling capabilities
  • Reasoning - Advanced reasoning models

Authentication

The gateway accepts authentication via the key query parameter:
  • Virtual Key: Use a virtual key (starts with sk-hk-) for managed access control
  • Direct API Key: Use your Google Gemini API key directly