Quickstart
API 사용을 위한 빠른 시작 가이드
Last updated
API 사용을 위한 빠른 시작 가이드
Last updated
UNIVA AI Platform의 모든 서비스는 API key를 통해 이용하실 수 있습니다.
Tips. API key 발급 필요 사항
AI Platform 회원가입
계정 신용카드 등록
좌측 메뉴, API Keys에서 + API Key 생성하기
클릭
비밀 키 생성 팝업에서 API Key 생성
버튼 클릭
생성된 API Key 확인
curl -X POST 'https://aiplatform-api.rest.univa.co.kr/rest/v1/text/komodo-small' \
-H 'Content-Type: application/json' \
-H 'x-api-key: UNIVA-API-KEY' \
-d '{
"data": {
"model": "komodo-small",
# 버전 설정 방법 : komodo-small-{version}
"stream": false,
"messages": [
{
"role": "system",
"content": "당신은 AI 챗봇 Komodo입니다. 사용자의 질문에 자세하고 친절하게 답변하세요."
},
{
"role": "user",
"content": "커피와 어울리는 디저트를 추천해줘"
}
],
"max_tokens": 128,
"temperature": 0.7,
"top_p": 1,
"top_k": -1,
"repetition_penalty": 1.15
}
}'
const axios = require('axios')
const apiKey = 'UNIVA-API-KEY'
const apiUrl =
'https://aiplatform-api-dev.rest.univa.co.kr/rest/v1/text/komodo-small'
const data = {
data: {
model: 'komodo-small',
// 버전 설정 방법 : komodo-small-{version}
stream: false,
messages: [
{
role: 'system',
content:
'당신은 AI 챗봇 Komodo입니다. 사용자의 질문에 자세하고 친절하게 답변하세요.',
},
{
role: 'user',
content: '커피와 어울리는 디저트를 추천해줘',
},
],
max_tokens: 128,
temperature: 0.01,
top_p: 0.9,
top_k: 20,
repetition_penalty: 1.15,
},
}
async function komodoPostRequest() {
try {
const response = await axios.post(apiUrl, data, {
headers: {
'Content-Type': 'application/json',
'x-api-key': apiKey,
},
})
// 응답 처리
if (response.status === 200) {
console.log('응답 데이터:', response.data)
// response.data를 파일로 저장하거나 다른 작업을 수행할 수 있습니다.
} else {
console.log('요청 실패:', response.statusText)
}
} catch (error) {
console.error('에러 발생:', error)
}
}
komodoPostRequest()
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
public class HttpPostExample {
public static void main(String[] args) {
String apiKey = "UNIVA-API-KEY"; // API 키를 입력하세요.
String url = "https://aiplatform-api.rest.univa.co.kr/rest/v1/text/komodo-small";
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(url);
httpPost.setHeader("Content-Type", "application/json");
httpPost.setHeader("x-api-key", apiKey); // API 키를 헤더에 추가합니다.
// JSON 형식의 body 데이터
String json = "{\"data\":{\"model\":\"komodo-small\",\"stream\":false,\"messages\":[{\"role\":\"system\",\"content\":\"당신은 AI챗봇 Komodo 입니다. 사용자의 질문에 자세하고 친절하게 답변하세요.\"},{\"role\":\"user\",\"content\":\"커피와 어울리는 디저트를 추천해줘\"}],\"max_tokens\":128,\"temperature\":0.01,\"top_p\":0.9,\"top_k\":20,\"repetition_penalty\":1.15}}";
// 버전 설정 방법 : komodo-small-{version}
StringEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON);
httpPost.setEntity(entity);
try {
HttpResponse response = httpClient.execute(httpPost);
HttpEntity responseEntity = response.getEntity();
String responseString = EntityUtils.toString(responseEntity, "UTF-8");
System.out.println(responseString);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
httpClient.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
import requests
import json
url = 'https://aiplatform-api.rest.univa.co.kr/rest/v1/text/komodo-small'
api_key = 'UNIVA-API-KEY'
headers = {
'Content-Type': 'application/json',
'x-api-key': api_key
}
data = {
"data" : {
"model": "komodo-small",
# 버전 설정 방법 : komodo-small-{version}
"stream": False,
"messages": [
{
"role": "system",
"content": "당신은 AI 챗봇 Komodo입니다. 사용자의 질문에 자세하고 친절하게 답변하세요."
},
{
"role": "user",
"content": "커피와 어울리는 디저트를 추천해줘"
}
],
"max_tokens": 512,
"temperature": 0.7,
"top_p": 1,
"top_k": -1,
"repetition_penalty": 1.15
}
}
response = requests.post(url, headers=headers, data=json.dumps(data))
# API 호출 결과 확인
if response.status_code == 200:
if response.status_code == 200:
result = response.json()
else:
print("Error Code :", response.status_code)
result = response.json()
result
{
"success": true,
"result": {
"id": "cmpl-054c224e62cf49bea2a34fd2cd07a265",
"object": "chat.completion",
"created": 1720754064,
"model": "komodo-small",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "커피와 어울리는 디저트는 다양하지만, 대표적인 몇 가지를 소개하겠습니다. \n1. 카페모카: 커피의 진한 맛과 초콜릿의 부드러움이 어우러진 디저트입니다.\n2. 카라멜 치즈 타르트: 부드럽고 진한 카라멜 소스와 크림치즈의 풍미가 조화로운 디저트로, 커피와 잘 어울립니다.\n3. 바나나 와플: 신선한 바나나와 달달한 시럽이 함께 얹어져 있어 커피 한 잔과 함께 즐기기에 좋습니다.\n4. 휘핑 크림을 올린 아이스 아메리카노: 시원한 커피에 생크림이나휘핑크림을 올려 마시는 것은 여름철 인기있는 조합입니다. \n이는 단지 몇 가지 예시일 뿐이며, 개인의 취향에 따라 다양한 디저트를 선택할 수 있습니다."
},
"logprobs": null,
"finish_reason": "stop",
"stop_reason": null
}
],
"usage": {
"prompt_tokens": 47,
"total_tokens": 225,
"completion_tokens": 178
}
}
}