Gemini AI
Category: AI & Agents
This page is generated from the Air Pipe marketplace. Browse it live to install into your organization.
Query Google's Gemini models over a simple HTTP API. Three variants: return the full Gemini payload, extract just the answer text, or constrain the answer with an instruction prefix. The API key and model are managed variables — swap models without touching the config or redeploying.
What's included
| File | Purpose |
|---|---|
config.yml | Air Pipe config with docs: true |
Endpoints
| Method | Path | Description |
|---|---|---|
POST | /gemini/query | Send a prompt, receive Gemini's full response payload |
POST | /gemini/query-text | Send a prompt, receive only the answer text |
POST | /gemini/query-prefixed | Constrain the answer with a fixed instruction prefix |
Setup
1. Get a Google AI Studio API key
Create a key at https://aistudio.google.com/app/apikey.
2. Set managed variables
| Variable | Example | Notes |
|---|---|---|
GEMINI_API_KEY | AIza… | Your AI Studio API key (store as a secret) |
GEMINI_MODEL | gemini-2.5-flash | Any Gemini model that supports generateContent |
Free-tier note: available models vary by key. A
429withlimit: 0means that model isn't on your key's free tier (e.g.gemini-2.0-flashoften isn't) — switchGEMINI_MODELtogemini-2.5-flash/gemini-flash-latest, or enable billing.
3. Deploy the pack and call it
curl -X POST https://<your-airpipe-host>/gemini/query-text \
-H 'content-type: application/json' \
-d '{"text": "Tell me about dogs"}'
Response (/gemini/query-text):
{ "data": { "QueryGemini": { "data": "Dogs are loyal, intelligent companions..." } } }
Use /gemini/query instead if you need the full Gemini payload (candidates,
safety ratings, token usage), or /gemini/query-prefixed to force short answers.
How it works
Each endpoint validates the incoming text, then calls the Gemini
generateContent API with the model and key from managed variables. The
query-text and query-prefixed variants add a post_transforms step that
pulls candidates[0].content.parts[0].text out of the response with jq.
Configuration
config.yml
name: GeminiAI
description: >
Query Google's Gemini models over a simple HTTP API. Three variants: return
the full Gemini payload, extract just the answer text, or constrain the answer
with a system-style prefix. The API key and model are managed variables — swap
models without redeploying.
docs: true
# Required managed variables:
# GEMINI_API_KEY — Google AI Studio API key (https://aistudio.google.com/app/apikey)
# GEMINI_MODEL — Model name, e.g. gemini-2.5-flash
interfaces:
# POST /gemini/query
# Validate the prompt, call Gemini, return the full response payload.
gemini/query:
output: http
method: POST
summary: Query Gemini (full payload)
description: Send a prompt and receive Gemini's complete response.
tags: [gemini, ai]
request_example:
text: "Tell me about dogs"
actions:
- name: CheckBody
input: a|body|
hide_data_on_success: true
assert:
http_code_on_error: 400
tests:
- value: text
is_not_null: true
is_not_empty: true
description: "The prompt to send to the model"
- name: QueryGemini
run_when_succeeded: [CheckBody]
http:
url: https://generativelanguage.googleapis.com/v1beta/models/a|ap_var::GEMINI_MODEL|:generateContent?key=a|ap_var::GEMINI_API_KEY|
method: POST
headers:
content-type: application/json
body: |
{"contents":[{"parts":[{"text":"a|CheckBody::text->json_escape|"}]}]}
# POST /gemini/query-text
# Same as above but extracts only the answer text from the payload.
gemini/query-text:
output: http
method: POST
summary: Query Gemini (answer text only)
description: Send a prompt and receive only the model's answer text.
tags: [gemini, ai]
request_example:
text: "Tell me about dogs"
actions:
- name: CheckBody
input: a|body|
hide_data_on_success: true
assert:
http_code_on_error: 400
tests:
- value: text
is_not_null: true
is_not_empty: true
- name: QueryGemini
run_when_succeeded: [CheckBody]
http:
url: https://generativelanguage.googleapis.com/v1beta/models/a|ap_var::GEMINI_MODEL|:generateContent?key=a|ap_var::GEMINI_API_KEY|
method: POST
headers:
content-type: application/json
body: |
{"contents":[{"parts":[{"text":"a|CheckBody::text->json_escape|"}]}]}
post_transforms:
- extract_with_jq: ".body.candidates[0].content.parts[0].text"
# POST /gemini/query-prefixed
# Constrain the answer by prepending an instruction to the prompt.
gemini/query-prefixed:
output: http
method: POST
summary: Query Gemini with an instruction prefix
description: >
Prepend a fixed instruction to every prompt to constrain the response
(e.g. "answer in one short sentence").
tags: [gemini, ai]
request_example:
text: "Tell me about dogs"
actions:
- name: CheckBody
input: a|body|
hide_data_on_success: true
assert:
http_code_on_error: 400
tests:
- value: text
is_not_null: true
is_not_empty: true
- name: QueryGemini
run_when_succeeded: [CheckBody]
http:
url: https://generativelanguage.googleapis.com/v1beta/models/a|ap_var::GEMINI_MODEL|:generateContent?key=a|ap_var::GEMINI_API_KEY|
method: POST
headers:
content-type: application/json
body: |
{"contents":[{"parts":[{"text":"Answer in one short sentence: a|CheckBody::text->json_escape|"}]}]}
post_transforms:
- extract_with_jq: ".body.candidates[0].content.parts[0].text"