Gemini 호환 콘텐츠 생성
curl --request POST \
--url https://apiany.ai/v1beta/models/{model}:generateContent \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"contents": [
{
"parts": [
{}
],
"role": "<string>"
}
],
"generationConfig": {
"temperature": 1,
"topP": 123,
"topK": 123,
"maxOutputTokens": 123,
"stopSequences": [
"<string>"
],
"responseMimeType": "<string>",
"responseSchema": {},
"responseModalities": [
"<string>"
]
},
"tools": [
{}
],
"systemInstruction": {}
}
'import requests
url = "https://apiany.ai/v1beta/models/{model}:generateContent"
payload = {
"contents": [
{
"parts": [{}],
"role": "<string>"
}
],
"generationConfig": {
"temperature": 1,
"topP": 123,
"topK": 123,
"maxOutputTokens": 123,
"stopSequences": ["<string>"],
"responseMimeType": "<string>",
"responseSchema": {},
"responseModalities": ["<string>"]
},
"tools": [{}],
"systemInstruction": {}
}
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: [{parts: [{}], role: '<string>'}],
generationConfig: {
temperature: 1,
topP: 123,
topK: 123,
maxOutputTokens: 123,
stopSequences: ['<string>'],
responseMimeType: '<string>',
responseSchema: {},
responseModalities: ['<string>']
},
tools: [{}],
systemInstruction: {}
})
};
fetch('https://apiany.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://apiany.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' => [
[
'parts' => [
[
]
],
'role' => '<string>'
]
],
'generationConfig' => [
'temperature' => 1,
'topP' => 123,
'topK' => 123,
'maxOutputTokens' => 123,
'stopSequences' => [
'<string>'
],
'responseMimeType' => '<string>',
'responseSchema' => [
],
'responseModalities' => [
'<string>'
]
],
'tools' => [
[
]
],
'systemInstruction' => [
]
]),
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://apiany.ai/v1beta/models/{model}:generateContent"
payload := strings.NewReader("{\n \"contents\": [\n {\n \"parts\": [\n {}\n ],\n \"role\": \"<string>\"\n }\n ],\n \"generationConfig\": {\n \"temperature\": 1,\n \"topP\": 123,\n \"topK\": 123,\n \"maxOutputTokens\": 123,\n \"stopSequences\": [\n \"<string>\"\n ],\n \"responseMimeType\": \"<string>\",\n \"responseSchema\": {},\n \"responseModalities\": [\n \"<string>\"\n ]\n },\n \"tools\": [\n {}\n ],\n \"systemInstruction\": {}\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://apiany.ai/v1beta/models/{model}:generateContent")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"contents\": [\n {\n \"parts\": [\n {}\n ],\n \"role\": \"<string>\"\n }\n ],\n \"generationConfig\": {\n \"temperature\": 1,\n \"topP\": 123,\n \"topK\": 123,\n \"maxOutputTokens\": 123,\n \"stopSequences\": [\n \"<string>\"\n ],\n \"responseMimeType\": \"<string>\",\n \"responseSchema\": {},\n \"responseModalities\": [\n \"<string>\"\n ]\n },\n \"tools\": [\n {}\n ],\n \"systemInstruction\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apiany.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 \"parts\": [\n {}\n ],\n \"role\": \"<string>\"\n }\n ],\n \"generationConfig\": {\n \"temperature\": 1,\n \"topP\": 123,\n \"topK\": 123,\n \"maxOutputTokens\": 123,\n \"stopSequences\": [\n \"<string>\"\n ],\n \"responseMimeType\": \"<string>\",\n \"responseSchema\": {},\n \"responseModalities\": [\n \"<string>\"\n ]\n },\n \"tools\": [\n {}\n ],\n \"systemInstruction\": {}\n}"
response = http.request(request)
puts response.read_body{
"candidates": [
{}
],
"usageMetadata": {}
}{
"error": {
"message": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"param": "<string>",
"code": "<string>"
}
}Chat
Gemini 호환 콘텐츠 생성
Gemini 호환 generateContent 엔드포인트입니다. 경로의 model은 APIAny.AI 공개 모델 ID입니다.
POST
/
v1beta
/
models
/
{model}
:generateContent
Gemini 호환 콘텐츠 생성
curl --request POST \
--url https://apiany.ai/v1beta/models/{model}:generateContent \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"contents": [
{
"parts": [
{}
],
"role": "<string>"
}
],
"generationConfig": {
"temperature": 1,
"topP": 123,
"topK": 123,
"maxOutputTokens": 123,
"stopSequences": [
"<string>"
],
"responseMimeType": "<string>",
"responseSchema": {},
"responseModalities": [
"<string>"
]
},
"tools": [
{}
],
"systemInstruction": {}
}
'import requests
url = "https://apiany.ai/v1beta/models/{model}:generateContent"
payload = {
"contents": [
{
"parts": [{}],
"role": "<string>"
}
],
"generationConfig": {
"temperature": 1,
"topP": 123,
"topK": 123,
"maxOutputTokens": 123,
"stopSequences": ["<string>"],
"responseMimeType": "<string>",
"responseSchema": {},
"responseModalities": ["<string>"]
},
"tools": [{}],
"systemInstruction": {}
}
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: [{parts: [{}], role: '<string>'}],
generationConfig: {
temperature: 1,
topP: 123,
topK: 123,
maxOutputTokens: 123,
stopSequences: ['<string>'],
responseMimeType: '<string>',
responseSchema: {},
responseModalities: ['<string>']
},
tools: [{}],
systemInstruction: {}
})
};
fetch('https://apiany.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://apiany.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' => [
[
'parts' => [
[
]
],
'role' => '<string>'
]
],
'generationConfig' => [
'temperature' => 1,
'topP' => 123,
'topK' => 123,
'maxOutputTokens' => 123,
'stopSequences' => [
'<string>'
],
'responseMimeType' => '<string>',
'responseSchema' => [
],
'responseModalities' => [
'<string>'
]
],
'tools' => [
[
]
],
'systemInstruction' => [
]
]),
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://apiany.ai/v1beta/models/{model}:generateContent"
payload := strings.NewReader("{\n \"contents\": [\n {\n \"parts\": [\n {}\n ],\n \"role\": \"<string>\"\n }\n ],\n \"generationConfig\": {\n \"temperature\": 1,\n \"topP\": 123,\n \"topK\": 123,\n \"maxOutputTokens\": 123,\n \"stopSequences\": [\n \"<string>\"\n ],\n \"responseMimeType\": \"<string>\",\n \"responseSchema\": {},\n \"responseModalities\": [\n \"<string>\"\n ]\n },\n \"tools\": [\n {}\n ],\n \"systemInstruction\": {}\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://apiany.ai/v1beta/models/{model}:generateContent")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"contents\": [\n {\n \"parts\": [\n {}\n ],\n \"role\": \"<string>\"\n }\n ],\n \"generationConfig\": {\n \"temperature\": 1,\n \"topP\": 123,\n \"topK\": 123,\n \"maxOutputTokens\": 123,\n \"stopSequences\": [\n \"<string>\"\n ],\n \"responseMimeType\": \"<string>\",\n \"responseSchema\": {},\n \"responseModalities\": [\n \"<string>\"\n ]\n },\n \"tools\": [\n {}\n ],\n \"systemInstruction\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apiany.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 \"parts\": [\n {}\n ],\n \"role\": \"<string>\"\n }\n ],\n \"generationConfig\": {\n \"temperature\": 1,\n \"topP\": 123,\n \"topK\": 123,\n \"maxOutputTokens\": 123,\n \"stopSequences\": [\n \"<string>\"\n ],\n \"responseMimeType\": \"<string>\",\n \"responseSchema\": {},\n \"responseModalities\": [\n \"<string>\"\n ]\n },\n \"tools\": [\n {}\n ],\n \"systemInstruction\": {}\n}"
response = http.request(request)
puts response.read_body{
"candidates": [
{}
],
"usageMetadata": {}
}{
"error": {
"message": "<string>",
"param": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"param": "<string>",
"code": "<string>"
}
}인증
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
경로 매개변수
본문
application/json
Show child attributes
Show child attributes
생성 설정입니다. 참고로, :generateContent 대신 :streamGenerateContent를 호출하면 Gemini SSE 스트림을 받을 수 있습니다.
Show child attributes
Show child attributes
모델이 호출할 수 있는 functionDeclarations를 포함하는 도구입니다.
시스템 지침으로, Gemini Content 객체({ parts: [{ text }] }) 형식입니다.
⌘I