Gemini Native
The native Gemini API puts the model in /v1beta/models/{model}:generateContent and authenticates with x-goog-api-key.
curl
bash
# Keep :generateContent at the end of the URL.
curl "https://sprelaytoken.com/v1beta/models/gemini-3-flash-preview:generateContent" \
-H "x-goog-api-key: $SPRELAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [
{
"role": "user",
"parts": [
{"text": "Explain an API gateway in one sentence."}
]
}
]
}'contents is the message array and parts holds content blocks. Replace the sample model with an exact currently available ID. JSON does not allow comments inside the body.
Python HTTP example
python
# requests sends HTTP; os reads the key from the environment.
import os
import requests
# The model ID becomes part of the native URL.
model = "gemini-3-flash-preview"
url = f"https://sprelaytoken.com/v1beta/models/{model}:generateContent"
# headers carries authentication; json is the request body; timeout prevents an endless wait.
response = requests.post(
url,
headers={
"x-goog-api-key": os.environ["SPRELAY_API_KEY"],
"Content-Type": "application/json",
},
json={
"contents": [
{
"role": "user",
"parts": [{"text": "Explain an API gateway in one sentence."}],
}
]
},
timeout=60,
)
# Raise an exception for 4xx/5xx before treating the body as success.
response.raise_for_status()
print(response.json())Text commonly appears at:
text
candidates[0].content.parts[0].textProduction code must also handle empty candidates, safety blocks, and multiple parts. Do not mix Gemini contents/parts with OpenAI messages.
