Skip to main content

API Code Invocation

  • Campus teachers and students can use the API Key to call the AIGC API service through code
  • For the list of large models provided by AIGC, please refer to: Model List

API Endpoints

  • AIGC currently provides V1 and V2 versions of API endpoints. After September 4, 2026, requests to the V1 version API will be automatically forwarded to the V2 version for unified request scheduling and response.
  • AIGC uniformly forwards requests to the backend large models through the LiteLLM Proxy service
API VersionAPI EndpointAPI Protocol FormatAPI Request Parameters (LiteLLM)
V2- https://aigc-api.hkust-gz.edu.cn/api/v2/chat/completions
- https://aigc-api.hkust-gz.edu.cn/api/v2/embeddings
OPENAIlitellm-completion input parameters
V1- https://aigc-api.hkust-gz.edu.cn/v1/chat/completions
- https://aigc-api.hkust-gz.edu.cn/v1/embeddings
OPENAIlitellm-embedding input parameters

API Authentication

The platform API uses Bearer Token for authentication. All requests must carry the API Key in the HTTP Header.

Header Format

Authorization: Bearer your_api_key
Content-Type: application/json

Security Recommendations

  • Do not hardcode the API Key in your code
  • It is recommended to read the key through environment variables or a key management service

Invocation Examples

CURL: Chat Completion

curl -X POST https://aigc-api.hkust-gz.edu.cn/api/v2/chat/completions \
-H "Authorization: Bearer ${API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"model": "DeepSeek-V4-Pro",
"messages": [
{"role": "system", "content": "你是一个有用的助手"},
{"role": "user", "content": "请介绍一下自己"}
],
}'

Python: Chat Completion

import os
import requests

API_KEY = os.getenv("AIGC_API_KEY")
url = "https://aigc-api.hkust-gz.edu.cn/api/v2/chat/completions"

headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}

payload = {
"model": "DeepSeek-V4-Pro",
"messages": [
{"role": "system", "content": "你是一个有用的助手"},
{"role": "user", "content": "请介绍一下自己"}
],
}

response = requests.post(url, headers=headers, json=payload)
print(response.json())