curl "https://api.pipellm.ai/v1beta/models/gemini-3-flash-preview:generateContent" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $PIPELLM_API_KEY" \
-d '{
"contents": [{"role": "user", "parts": [{"text": "Hello"}]}]
}'
import os
from google import genai
client = genai.Client(
api_key=os.environ["PIPELLM_API_KEY"],
http_options={"base_url": "https://api.pipellm.ai"},
)
print(client.models.generate_content(
model="gemini-3-flash-preview",
contents="Hello",
).text)
{
"candidates": [
{
"content": {},
"finishReason": "<string>"
}
],
"usageMetadata": {}
}Generate content
Generate content with the Gemini generateContent API.
POST
/
v1beta
/
models
/
{model}
:generateContent
curl "https://api.pipellm.ai/v1beta/models/gemini-3-flash-preview:generateContent" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $PIPELLM_API_KEY" \
-d '{
"contents": [{"role": "user", "parts": [{"text": "Hello"}]}]
}'
import os
from google import genai
client = genai.Client(
api_key=os.environ["PIPELLM_API_KEY"],
http_options={"base_url": "https://api.pipellm.ai"},
)
print(client.models.generate_content(
model="gemini-3-flash-preview",
contents="Hello",
).text)
{
"candidates": [
{
"content": {},
"finishReason": "<string>"
}
],
"usageMetadata": {}
}Native Gemini path. Streaming uses
POST /v1beta/models/{model}:streamGenerateContent.
curl "https://api.pipellm.ai/v1beta/models/gemini-3-flash-preview:generateContent" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $PIPELLM_API_KEY" \
-d '{
"contents": [{"role": "user", "parts": [{"text": "Hello"}]}]
}'
import os
from google import genai
client = genai.Client(
api_key=os.environ["PIPELLM_API_KEY"],
http_options={"base_url": "https://api.pipellm.ai"},
)
print(client.models.generate_content(
model="gemini-3-flash-preview",
contents="Hello",
).text)
string
required
Gemini model ID, for example
gemini-3-flash-preview.array
required
object
Endpoint
POST https://api.pipellm.ai/v1beta/models/{model}:generateContent
This free route accepts Gemini native requests and routes only to Gemini
platforms. To keep the Gemini format while calling OpenAI or Anthropic
models, use the Gemini Format Converter.
Install SDK
pip install google-genai
Code Examples
- cURL
- Python
- Node.js
- Go
curl "https://api.pipellm.ai/v1beta/models/gemini-3-flash-preview:generateContent" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $PIPELLM_API_KEY" \
-d '{
"contents": [
{
"role": "user",
"parts": [
{"text": "Why is the sky blue?"}
]
}
]
}'
import os
from google import genai
client = genai.Client(
api_key=os.getenv('PIPELLM_API_KEY'),
http_options={'base_url': 'https://api.pipellm.ai'}
)
response = client.models.generate_content(
model='gemini-3-flash-preview',
contents='Why is the sky blue?'
)
print(response.text)
import { GoogleGenAI } from '@google/genai';
const ai = new GoogleGenAI({
apiKey: process.env.PIPELLM_API_KEY,
httpOptions: {
baseUrl: 'https://api.pipellm.ai'
}
});
const response = await ai.models.generateContent({
model: 'gemini-3-flash-preview',
contents: 'Why is the sky blue?'
});
console.log(response.text);
package main
import (
"context"
"os"
"github.com/google/generative-ai-go/genai"
"google.golang.org/api/option"
)
func main() {
ctx := context.Background()
client, _ := genai.NewClient(ctx,
option.WithAPIKey(os.Getenv("PIPELLM_API_KEY")),
option.WithEndpoint("https://api.pipellm.ai"),
)
defer client.Close()
model := client.GenerativeModel("gemini-3-flash-preview")
resp, _ := model.GenerateContent(ctx,
genai.Text("Why is the sky blue?"),
)
}
Request Format
{
"contents": [
{
"role": "user",
"parts": [
{"text": "Your message here"}
]
}
],
"generationConfig": {
"temperature": 0.7,
"maxOutputTokens": 1024
}
}
Response Format
{
"candidates": [
{
"content": {
"parts": [
{"text": "The sky appears blue because..."}
],
"role": "model"
},
"finishReason": "STOP"
}
],
"usageMetadata": {
"promptTokenCount": 10,
"candidatesTokenCount": 50,
"totalTokenCount": 60
}
}
array
object
promptTokenCount, candidatesTokenCount, totalTokenCount.Errors
Same envelope as Errors. Usex-goog-api-key. Native Gemini routes return 400 when the body is not Gemini format.
400 invalid_request_error
400 invalid_request_error
Missing
contents, unknown model ID, or a protocol mismatch.{
"error": {
"type": "invalid_request_error",
"code": "400",
"message": "The 'model' field is required but was not provided in the request"
}
}
401 authentication_error
401 authentication_error
Missing or invalid
x-goog-api-key.{
"error": {
"type": "authentication_error",
"code": "401",
"message": "Incorrect API key provided. Please visit https://console.pipellm.ai/account/api-keys to find your API key."
}
}
402 insufficient_balance
402 insufficient_balance
{
"error": {
"type": "insufficient_balance",
"code": "402",
"message": "Insufficient balance. Please recharge your account at https://console.pipellm.ai/billing."
}
}
429 rate_limit_error
429 rate_limit_error
See Rate Limits.
{
"error": {
"type": "rate_limit_error",
"code": "429",
"message": "Rate limit exceeded. Your current limit is 120 requests per minute (approximately 2.00 requests per second). Please visit https://console.pipellm.ai/billing to upgrade your plan for higher limits."
}
}
Related Docs
Routing & Protocols
Native-route constraints and converter routes
Gemini Overview
Headers, models, and route family overview
Gemini Format Converter
Keep Gemini format while calling other providers
Was this page helpful?