기능별

채팅

모델을 고르고, 요청을 복사하고, 답변을 읽으세요. 모든 채팅 모델은 같은 OpenAI 스타일 요청을 받습니다.

#1. 모델 선택

#3. 결과 받기

200 응답의 답변은 choices[0].message.content에 있습니다. 생성되는 동안 받으려면 "stream": true를 추가하세요.

#문제가 생겼을 때

  • 필드 이름과 함께 400: 이 모델이 받지 않는 옵션입니다. 2단계에 나열된 값을 사용하세요.
  • 402: 잔액이 이 요청에 부족합니다. 지갑에서 충전한 뒤 다시 시도하세요.
  • 429: 요청 속도를 줄이고 Retry-After 초만큼 기다린 뒤 다시 시도하세요.
  • 503 model_not_found: 모델 이름이 틀렸거나 모델이 오프라인입니다. 1단계에서 다시 고르세요.

다른 오류 찾아보기 →

스트리밍작성되는 동안 답변을 표시합니다.

#작동 방식

stream:true로 설정하면 게이트웨이가 OpenAI와 똑같은 방식으로 Server-Sent Events를 전달합니다. 델타마다 data: 프레임 하나, 마지막은 data: [DONE]입니다. 모든 SSE 클라이언트나 공식 SDK에서 그대로 사용할 수 있습니다.

#실행하기

terminal — live
curl -N https://www.aisplice.store/v1/chat/completions \
  -H "Authorization: Bearer sk-YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.6-luna",
    "stream": true,
    "messages": [
      {
        "role": "user",
        "content": "Write a haiku about the sea."
      }
    ]
  }'
streaming.py
from openai import OpenAI

client = OpenAI(base_url="https://www.aisplice.store/v1", api_key="sk-YOUR_KEY")

stream = client.chat.completions.create(
    model="gpt-5.6-luna",
    stream=True,
    messages=[{"role": "user", "content": "Write a haiku about the sea."}],
)
for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="")

#부분 과금

스트리밍된 만큼만 지불

클라이언트가 스트림 도중 연결을 끊으면 게이트웨이는 실제로 전송된 부분 사용량만 기록합니다 — 전달된 만큼만 과금됩니다.
도구 호출모델이 직접 만든 함수를 호출하게 합니다.

#도구 선언

표준 OpenAI tools 배열을 보내세요. 게이트웨이는 도구를 지원하는 모든 모델 — OpenAI, Claude, Gemini, DeepSeek — 에 이를 전달하고, 응답을 tool_calls로 정규화합니다. 스트리밍 도구 호출 델타도 지원됩니다.

tools.sh
curl https://www.aisplice.store/v1/chat/completions \
  -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.6-luna",
    "messages": [{"role":"user","content":"Weather in Tokyo?"}],
    "tools": [{
      "type": "function",
      "function": {
        "name": "get_weather",
        "parameters": {
          "type": "object",
          "properties": {"city": {"type": "string"}},
          "required": ["city"]
        }
      }
    }]
  }'

#tool_calls 처리

모델이 도구 호출을 결정하면 choice가 finish_reason:"tool_calls"와 함께 오며, 코드에서 arguments 문자열을 파싱해 실행합니다.

response.json
{
  "choices": [{
    "finish_reason": "tool_calls",
    "message": {
      "role": "assistant",
      "tool_calls": [{
        "id": "call_abc123",
        "type": "function",
        "function": {
          "name": "get_weather",
          "arguments": "{\"city\": \"Tokyo\"}"
        }
      }]
    }
  }]
}

#결과 돌려보내기

assistant 턴과 호출마다 role:"tool" 메시지 하나씩(tool_call_id로 매칭)을 추가한 뒤 다시 요청하세요 — 모델이 결과를 최종 답변에 반영합니다.

round-trip.sh
curl https://www.aisplice.store/v1/chat/completions \
  -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.6-luna",
    "messages": [
      {"role":"user","content":"Weather in Tokyo?"},
      {"role":"assistant","tool_calls":[{"id":"call_abc123","type":"function",
        "function":{"name":"get_weather","arguments":"{\"city\":\"Tokyo\"}"}}]},
      {"role":"tool","tool_call_id":"call_abc123","content":"{\"temp_c\": 22, \"sky\": \"clear\"}"}
    ]
  }'
이미지 입력텍스트와 함께 이미지를 보냅니다.

#이미지 보내기

비전을 지원하는 채팅 모델은 text 파트와 image_url 파트를 섞은 content 배열을 받습니다. 공개 URL이나 인라인 base64 data URL을 사용하세요 — 어느 쪽이든 같은 필드입니다.

vision.sh
curl https://www.aisplice.store/v1/chat/completions \
  -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.6-luna",
    "messages": [{
      "role": "user",
      "content": [
        {"type": "text", "text": "What is in this image?"},
        {"type": "image_url", "image_url": {"url": "https://example.com/cat.png"}}
      ]
    }]
  }'

#Base64 이미지

로컬 파일은 data URL로 인라인하세요: "url": "data:image/png;base64,<bytes>". 이미지 토큰은 입력 토큰으로 과금되며, 요청당 최대 이미지 크기와 개수는 제공업체마다 다릅니다 — 보내기 전에 축소하면 비용을 아낄 수 있습니다.

base64.py
import base64
from openai import OpenAI

client = OpenAI(base_url="https://www.aisplice.store/v1", api_key="sk-YOUR_KEY")
b64 = base64.b64encode(open("photo.png", "rb").read()).decode()

resp = client.chat.completions.create(
    model="gpt-5.6-luna",
    messages=[{"role": "user", "content": [
        {"type": "text", "text": "Describe this photo."},
        {"type": "image_url", "image_url": {"url": f"data:image/png;base64,{b64}"}},
    ]}],
)
print(resp.choices[0].message.content)

아직 해결되지 않았나요?

요청 ID나 오류 메시지를 보내 주시면 확인해 드리겠습니다.