TokenHub Quick Start
On this page
TokenHub는 OpenAI API 프로토콜과 호환되는 LLM 게이트웨이입니다. 이 문서는 콘솔 개통부터 첫 모델 호출까지의 절차를 안내합니다.
사전 준비
서비스 활성화
TokenHub 콘솔에 로그인하고 화면 안내에 따라 서비스를 활성화합니다. 개통 후 Model Gallery에서 제공 모델을 확인할 수 있습니다. 모델별 상세 정보는 Model List를 참조하세요.
모델 선택
TokenHub는 모델별 후과금(pay-as-you-go) 방식으로 과금됩니다. 사용할 모델을 Online Inference 목록에서 찾아 활성화합니다.
API Key 발급
- API Key 페이지로 이동합니다.
- 페이지 상단에서 리전을 선택한 후 Create a Key를 클릭합니다.
- Create a Key 대화 상자에서 Key Name을 입력하고 Accessible Range를 설정합니다.
- Select All: 현재 계정의 모든 모델과 추론 서비스에 접근합니다.
- Defined Range: 특정 모델과 추론 서비스만 선택해 접근을 제한합니다.
- Confirm을 클릭해 생성합니다.
생성 직후 표시되는 API Key를 반드시 복사해 안전하게 저장하세요. 이후 API 호출의 인증에 사용됩니다. 자세한 관리 방법은 API Key 관리를 참조하세요.
첫 모델 호출
TokenHub는 OpenAI API 프로토콜과 호환되므로 기존 OpenAI SDK를 그대로 사용할 수 있습니다. 예시의 YOUR_API_KEY를 발급받은 키로, model 값을 사용할 모델로 교체하세요. 모델 값은 Model List의 Model (API Parameter) 항목에서 확인합니다.
LANGUAGE
curl -X POST 'https://tokenhub-intl.tencentcloudmaas.com/v1/chat/completions' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"model": "deepseek-v3.2",
"messages": [
{
"role": "user",
"content": "hello"
}
],
"stream": true
}'
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://tokenhub-intl.tencentcloudmaas.com/v1"
)
response = client.chat.completions.create(
model="deepseek-v3.2",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello, please introduce yourself"}
]
)
print(response.choices[0].message.content)
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: 'YOUR_API_KEY',
baseURL: 'https://tokenhub-intl.tencentcloudmaas.com/v1',
});
async function main() {
const response = await client.chat.completions.create({
model: 'deepseek-v3.2',
messages: [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'Hello, please introduce yourself' },
],
});
console.log(response.choices[0].message.content);
}
main();
import java.net.http.*;
import java.net.URI;
public class MaaSExample {
public static void main(String[] args) throws Exception {
String apiKey = "YOUR_API_KEY";
String body = """
{
"model": "deepseek-v3.2",
"messages": [{"role": "user", "content": "hello"}]
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://tokenhub-intl.tencentcloudmaas.com/v1/chat/completions"))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
HttpClient client = HttpClient.newHttpClient();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
apiKey := "YOUR_API_KEY"
body := map[string]interface{}{
"model": "deepseek-v3.2",
"messages": []map[string]string{
{"role": "user", "content": "hello"},
},
}
jsonBody, _ := json.Marshal(body)
req, _ := http.NewRequest("POST",
"https://tokenhub-intl.tencentcloudmaas.com/v1/chat/completions",
bytes.NewBuffer(jsonBody))
req.Header.Set("Authorization", "Bearer "+apiKey)
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
result, _ := io.ReadAll(resp.Body)
fmt.Println(string(result))
}
예시는 Singapore 사이트 엔드포인트 기준입니다. 리전별 엔드포인트는 API 사용 가이드를 참조하세요.
