REST API
HTTP를 직접 사용하는 방식으로, SDK 설치 없이 모든 언어와 환경에서 즉시 사용할 수 있습니다.
curl, Go, Java, PHP, Ruby 등 HTTP 요청이 가능한 환경이라면 어디서든 연동 가능합니다.
엔드포인트
POST https://ai-api.iwinv.kr/v1/chat/completions
요청 헤더
Authorization: Bearer sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Content-Type: application/json
기본 요청
- cURL
- Go
- Java
- PHP
curl https://ai-api.iwinv.kr/v1/chat/completions \
-H "Authorization: Bearer $IWINV_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemma4-26b",
"messages": [
{"role": "system", "content": "당신은 친절한 AI 어시스턴트입니다."},
{"role": "user", "content": "안녕하세요!"}
],
"max_tokens": 512,
"temperature": 0.7
}'
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
)
func main() {
body, _ := json.Marshal(map[string]interface{}{
"model": "gemma4-26b",
"messages": []map[string]string{
{"role": "system", "content": "당신은 친절한 AI 어시스턴트입니다."},
{"role": "user", "content": "안녕하세요!"},
},
"max_tokens": 512,
})
req, _ := http.NewRequest("POST",
"https://ai-api.iwinv.kr/v1/chat/completions",
bytes.NewBuffer(body),
)
req.Header.Set("Authorization", "Bearer "+os.Getenv("IWINV_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
result, _ := io.ReadAll(resp.Body)
fmt.Println(string(result))
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class IwinvAPI {
public static void main(String[] args) throws Exception {
String apiKey = System.getenv("IWINV_API_KEY");
String body = """
{
"model": "gemma4-26b",
"messages": [
{"role": "system", "content": "당신은 친절한 AI 어시스턴트입니다."},
{"role": "user", "content": "안녕하세요!"}
],
"max_tokens": 512
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://ai-api.iwinv.kr/v1/chat/completions"))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
<?php
$apiKey = getenv('IWINV_API_KEY');
$data = [
'model' => 'gemma4-26b',
'messages' => [
['role' => 'system', 'content' => '당신은 친절한 AI 어시스턴트입니다.'],
['role' => 'user', 'content' => '안녕하세요!']
],
'max_tokens' => 512,
'temperature' => 0.7
];
$ch = curl_init('https://ai-api.iwinv.kr/v1/chat/completions');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json'
]
]);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
echo $result['choices'][0]['message']['content'];