Generate Content
curl --request POST \
--url https://www.anyfast.ai/v1beta/models/{model}:generateContent \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Hello, Gemini!"
}
]
}
],
"systemInstruction": {
"parts": [
{
"text": "<string>"
}
]
},
"generationConfig": {
"temperature": 1,
"topP": 0.5,
"topK": 123,
"maxOutputTokens": 123,
"stopSequences": [
"<string>"
],
"responseSchema": {}
},
"tools": [
{
"functionDeclarations": [
{
"name": "<string>",
"description": "<string>",
"parameters": {}
}
]
}
],
"toolConfig": {
"functionCallingConfig": {
"allowedFunctionNames": [
"<string>"
]
}
},
"safetySettings": [
{}
]
}
'import requests
url = "https://www.anyfast.ai/v1beta/models/{model}:generateContent"
payload = {
"contents": [
{
"role": "user",
"parts": [{ "text": "Hello, Gemini!" }]
}
],
"systemInstruction": { "parts": [{ "text": "<string>" }] },
"generationConfig": {
"temperature": 1,
"topP": 0.5,
"topK": 123,
"maxOutputTokens": 123,
"stopSequences": ["<string>"],
"responseSchema": {}
},
"tools": [{ "functionDeclarations": [
{
"name": "<string>",
"description": "<string>",
"parameters": {}
}
] }],
"toolConfig": { "functionCallingConfig": { "allowedFunctionNames": ["<string>"] } },
"safetySettings": [{}]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
contents: [{role: 'user', parts: [{text: 'Hello, Gemini!'}]}],
systemInstruction: {parts: [{text: '<string>'}]},
generationConfig: {
temperature: 1,
topP: 0.5,
topK: 123,
maxOutputTokens: 123,
stopSequences: ['<string>'],
responseSchema: {}
},
tools: [
{
functionDeclarations: [{name: '<string>', description: '<string>', parameters: {}}]
}
],
toolConfig: {functionCallingConfig: {allowedFunctionNames: ['<string>']}},
safetySettings: [{}]
})
};
fetch('https://www.anyfast.ai/v1beta/models/{model}:generateContent', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://www.anyfast.ai/v1beta/models/{model}:generateContent",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'contents' => [
[
'role' => 'user',
'parts' => [
[
'text' => 'Hello, Gemini!'
]
]
]
],
'systemInstruction' => [
'parts' => [
[
'text' => '<string>'
]
]
],
'generationConfig' => [
'temperature' => 1,
'topP' => 0.5,
'topK' => 123,
'maxOutputTokens' => 123,
'stopSequences' => [
'<string>'
],
'responseSchema' => [
]
],
'tools' => [
[
'functionDeclarations' => [
[
'name' => '<string>',
'description' => '<string>',
'parameters' => [
]
]
]
]
],
'toolConfig' => [
'functionCallingConfig' => [
'allowedFunctionNames' => [
'<string>'
]
]
],
'safetySettings' => [
[
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://www.anyfast.ai/v1beta/models/{model}:generateContent"
payload := strings.NewReader("{\n \"contents\": [\n {\n \"role\": \"user\",\n \"parts\": [\n {\n \"text\": \"Hello, Gemini!\"\n }\n ]\n }\n ],\n \"systemInstruction\": {\n \"parts\": [\n {\n \"text\": \"<string>\"\n }\n ]\n },\n \"generationConfig\": {\n \"temperature\": 1,\n \"topP\": 0.5,\n \"topK\": 123,\n \"maxOutputTokens\": 123,\n \"stopSequences\": [\n \"<string>\"\n ],\n \"responseSchema\": {}\n },\n \"tools\": [\n {\n \"functionDeclarations\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {}\n }\n ]\n }\n ],\n \"toolConfig\": {\n \"functionCallingConfig\": {\n \"allowedFunctionNames\": [\n \"<string>\"\n ]\n }\n },\n \"safetySettings\": [\n {}\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://www.anyfast.ai/v1beta/models/{model}:generateContent")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"contents\": [\n {\n \"role\": \"user\",\n \"parts\": [\n {\n \"text\": \"Hello, Gemini!\"\n }\n ]\n }\n ],\n \"systemInstruction\": {\n \"parts\": [\n {\n \"text\": \"<string>\"\n }\n ]\n },\n \"generationConfig\": {\n \"temperature\": 1,\n \"topP\": 0.5,\n \"topK\": 123,\n \"maxOutputTokens\": 123,\n \"stopSequences\": [\n \"<string>\"\n ],\n \"responseSchema\": {}\n },\n \"tools\": [\n {\n \"functionDeclarations\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {}\n }\n ]\n }\n ],\n \"toolConfig\": {\n \"functionCallingConfig\": {\n \"allowedFunctionNames\": [\n \"<string>\"\n ]\n }\n },\n \"safetySettings\": [\n {}\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.anyfast.ai/v1beta/models/{model}:generateContent")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"contents\": [\n {\n \"role\": \"user\",\n \"parts\": [\n {\n \"text\": \"Hello, Gemini!\"\n }\n ]\n }\n ],\n \"systemInstruction\": {\n \"parts\": [\n {\n \"text\": \"<string>\"\n }\n ]\n },\n \"generationConfig\": {\n \"temperature\": 1,\n \"topP\": 0.5,\n \"topK\": 123,\n \"maxOutputTokens\": 123,\n \"stopSequences\": [\n \"<string>\"\n ],\n \"responseSchema\": {}\n },\n \"tools\": [\n {\n \"functionDeclarations\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {}\n }\n ]\n }\n ],\n \"toolConfig\": {\n \"functionCallingConfig\": {\n \"allowedFunctionNames\": [\n \"<string>\"\n ]\n }\n },\n \"safetySettings\": [\n {}\n ]\n}"
response = http.request(request)
puts response.read_body{
"candidates": [
{
"content": {
"parts": [
{
"text": "<string>"
}
],
"role": "model"
},
"index": 123,
"safetyRatings": [
{
"category": "<string>",
"probability": "<string>"
}
]
}
],
"usageMetadata": {
"promptTokenCount": 123,
"candidatesTokenCount": 123,
"totalTokenCount": 123
},
"modelVersion": "<string>"
}{
"error": {
"code": 123,
"message": "<string>",
"status": "<string>"
}
}{
"error": {
"code": 123,
"message": "<string>",
"status": "<string>"
}
}{
"error": {
"code": 123,
"message": "<string>",
"status": "<string>"
}
}Google Gemini
Generate Content
Generates a model response given an input GenerateContentRequest.
POST
/
v1beta
/
models
/
{model}
:generateContent
Generate Content
curl --request POST \
--url https://www.anyfast.ai/v1beta/models/{model}:generateContent \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Hello, Gemini!"
}
]
}
],
"systemInstruction": {
"parts": [
{
"text": "<string>"
}
]
},
"generationConfig": {
"temperature": 1,
"topP": 0.5,
"topK": 123,
"maxOutputTokens": 123,
"stopSequences": [
"<string>"
],
"responseSchema": {}
},
"tools": [
{
"functionDeclarations": [
{
"name": "<string>",
"description": "<string>",
"parameters": {}
}
]
}
],
"toolConfig": {
"functionCallingConfig": {
"allowedFunctionNames": [
"<string>"
]
}
},
"safetySettings": [
{}
]
}
'import requests
url = "https://www.anyfast.ai/v1beta/models/{model}:generateContent"
payload = {
"contents": [
{
"role": "user",
"parts": [{ "text": "Hello, Gemini!" }]
}
],
"systemInstruction": { "parts": [{ "text": "<string>" }] },
"generationConfig": {
"temperature": 1,
"topP": 0.5,
"topK": 123,
"maxOutputTokens": 123,
"stopSequences": ["<string>"],
"responseSchema": {}
},
"tools": [{ "functionDeclarations": [
{
"name": "<string>",
"description": "<string>",
"parameters": {}
}
] }],
"toolConfig": { "functionCallingConfig": { "allowedFunctionNames": ["<string>"] } },
"safetySettings": [{}]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
contents: [{role: 'user', parts: [{text: 'Hello, Gemini!'}]}],
systemInstruction: {parts: [{text: '<string>'}]},
generationConfig: {
temperature: 1,
topP: 0.5,
topK: 123,
maxOutputTokens: 123,
stopSequences: ['<string>'],
responseSchema: {}
},
tools: [
{
functionDeclarations: [{name: '<string>', description: '<string>', parameters: {}}]
}
],
toolConfig: {functionCallingConfig: {allowedFunctionNames: ['<string>']}},
safetySettings: [{}]
})
};
fetch('https://www.anyfast.ai/v1beta/models/{model}:generateContent', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://www.anyfast.ai/v1beta/models/{model}:generateContent",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'contents' => [
[
'role' => 'user',
'parts' => [
[
'text' => 'Hello, Gemini!'
]
]
]
],
'systemInstruction' => [
'parts' => [
[
'text' => '<string>'
]
]
],
'generationConfig' => [
'temperature' => 1,
'topP' => 0.5,
'topK' => 123,
'maxOutputTokens' => 123,
'stopSequences' => [
'<string>'
],
'responseSchema' => [
]
],
'tools' => [
[
'functionDeclarations' => [
[
'name' => '<string>',
'description' => '<string>',
'parameters' => [
]
]
]
]
],
'toolConfig' => [
'functionCallingConfig' => [
'allowedFunctionNames' => [
'<string>'
]
]
],
'safetySettings' => [
[
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://www.anyfast.ai/v1beta/models/{model}:generateContent"
payload := strings.NewReader("{\n \"contents\": [\n {\n \"role\": \"user\",\n \"parts\": [\n {\n \"text\": \"Hello, Gemini!\"\n }\n ]\n }\n ],\n \"systemInstruction\": {\n \"parts\": [\n {\n \"text\": \"<string>\"\n }\n ]\n },\n \"generationConfig\": {\n \"temperature\": 1,\n \"topP\": 0.5,\n \"topK\": 123,\n \"maxOutputTokens\": 123,\n \"stopSequences\": [\n \"<string>\"\n ],\n \"responseSchema\": {}\n },\n \"tools\": [\n {\n \"functionDeclarations\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {}\n }\n ]\n }\n ],\n \"toolConfig\": {\n \"functionCallingConfig\": {\n \"allowedFunctionNames\": [\n \"<string>\"\n ]\n }\n },\n \"safetySettings\": [\n {}\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://www.anyfast.ai/v1beta/models/{model}:generateContent")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"contents\": [\n {\n \"role\": \"user\",\n \"parts\": [\n {\n \"text\": \"Hello, Gemini!\"\n }\n ]\n }\n ],\n \"systemInstruction\": {\n \"parts\": [\n {\n \"text\": \"<string>\"\n }\n ]\n },\n \"generationConfig\": {\n \"temperature\": 1,\n \"topP\": 0.5,\n \"topK\": 123,\n \"maxOutputTokens\": 123,\n \"stopSequences\": [\n \"<string>\"\n ],\n \"responseSchema\": {}\n },\n \"tools\": [\n {\n \"functionDeclarations\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {}\n }\n ]\n }\n ],\n \"toolConfig\": {\n \"functionCallingConfig\": {\n \"allowedFunctionNames\": [\n \"<string>\"\n ]\n }\n },\n \"safetySettings\": [\n {}\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.anyfast.ai/v1beta/models/{model}:generateContent")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"contents\": [\n {\n \"role\": \"user\",\n \"parts\": [\n {\n \"text\": \"Hello, Gemini!\"\n }\n ]\n }\n ],\n \"systemInstruction\": {\n \"parts\": [\n {\n \"text\": \"<string>\"\n }\n ]\n },\n \"generationConfig\": {\n \"temperature\": 1,\n \"topP\": 0.5,\n \"topK\": 123,\n \"maxOutputTokens\": 123,\n \"stopSequences\": [\n \"<string>\"\n ],\n \"responseSchema\": {}\n },\n \"tools\": [\n {\n \"functionDeclarations\": [\n {\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"parameters\": {}\n }\n ]\n }\n ],\n \"toolConfig\": {\n \"functionCallingConfig\": {\n \"allowedFunctionNames\": [\n \"<string>\"\n ]\n }\n },\n \"safetySettings\": [\n {}\n ]\n}"
response = http.request(request)
puts response.read_body{
"candidates": [
{
"content": {
"parts": [
{
"text": "<string>"
}
],
"role": "model"
},
"index": 123,
"safetyRatings": [
{
"category": "<string>",
"probability": "<string>"
}
]
}
],
"usageMetadata": {
"promptTokenCount": 123,
"candidatesTokenCount": 123,
"totalTokenCount": 123
},
"modelVersion": "<string>"
}{
"error": {
"code": 123,
"message": "<string>",
"status": "<string>"
}
}{
"error": {
"code": 123,
"message": "<string>",
"status": "<string>"
}
}{
"error": {
"code": 123,
"message": "<string>",
"status": "<string>"
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
The model name to use for generation.
Available options:
gemini-3.1-pro-preview, gemini-3.1-flash-image, gemini-3.1-flash-lite-preview, gemini-3-pro-preview, gemini-3-pro-image, gemini-3-flash-preview, gemini-2.5-pro, gemini-2.5-flash, gemini-2.5-flash-lite, gemini-2.0-flash Body
application/json
The content of the current conversation with the model.
Minimum array length:
1Show child attributes
Show child attributes
Example:
[ { "role": "user", "parts": [{ "text": "Hello, Gemini!" }] } ]
Developer set system instruction.
Show child attributes
Show child attributes
Configuration options for model generation and outputs.
Show child attributes
Show child attributes
A list of tools the model may use to generate a response.
Show child attributes
Show child attributes
Tool configuration for any tools specified in the request.
Show child attributes
Show child attributes
A list of unique SafetySetting instances for blocking unsafe content.
Show child attributes
Show child attributes
Was this page helpful?
⌘I