Gemini API
activeGoogle's most capable AI model for text generation, reasoning, and conversation.
Googlechat2 credits/call
Provider
Google
Pricing
~$0.004 per request (2 credits)
Speed
1–5 seconds
Output
text
Quick Start
Send a request to the Gemini API:
bash
curl -X POST https://apiin.one/api/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini",
"messages": [
{
"role": "user",
"content": "Explain quantum computing in simple terms."
}
],
"temperature": 0.7,
"max_tokens": 1024
}'API Endpoint
POST
/api/v1/chat/completionsSend a POST request with your API key to generate content using Gemini.
Headers
| Header | 类型 | 必填 | 描述 |
|---|---|---|---|
Authorization | string | 必填 | Bearer YOUR_API_KEY |
Content-Type | string | 必填 | application/json |
Body Parameters
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
model | string | 必填 | Model identifier: "gemini" |
messages | array | 必填 | Array of message objects with role and content |
temperature | number | 可选 | Sampling temperature (0-2) (默认值: 0.7) |
max_tokens | number | 可选 | Maximum tokens in response (默认值: 4096) |
Example Request
json
{
"model": "gemini",
"messages": [
{
"role": "user",
"content": "Explain quantum computing in simple terms."
}
],
"temperature": 0.7,
"max_tokens": 1024
}Example Response
Successful completion response.
{
"id": "chatcmpl_mno345",
"model": "gemini",
"choices": [
{
"message": {
"role": "assistant",
"content": "Quantum computing uses quantum bits (qubits) that can be both 0 and 1 simultaneously..."
}
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 156,
"total_tokens": 168
},
"credits_consumed": 2
}Use Cases
- ✓Build AI-powered chatbots and customer support agents
- ✓Generate and summarize text content at scale
- ✓Create AI coding assistants and code generation tools
- ✓Power reasoning and analysis features in your application
API Tester
Test the Gemini API directly from your browser:
API 测试沙盒POST
Error Codes
{
"error": {
"code": 400,
"message": "Invalid parameters",
"type": "invalid_request"
}
}Frequently Asked Questions
Is the Gemini API compatible with OpenAI's format?
Yes. API in One uses the standard OpenAI chat/completions format. You can switch from OpenAI to Gemini by changing the base URL and model name — no other code changes needed.
How much does the Gemini API cost?
Each request costs 2 credits (~$0.004), making it one of the most affordable LLM APIs available. Free credits are included on sign up.
Does the Gemini API support streaming?
The API currently supports non-streaming responses. Streaming support is on our roadmap.
What is the maximum context length?
The Gemini API supports up to 128K tokens of context, suitable for processing long documents and maintaining extended conversations.
Why Use Gemini Through API in One?
1OpenAI-compatible /chat/completions format — drop-in replacement
2One of the cheapest LLM APIs available
3128K token context window for long documents
4No Google Cloud or Vertex AI setup required
Ready to use Gemini?
Get Your API Key →