메인 콘텐츠로 건너뛰기
OpenAI 스타일 tools / tool_choice는 채팅 가능한 모든 프로바이더 에서 작동합니다. 게이트웨이가 업스트림의 네이티브 도구 호출 형태로 변환합니다.

최소 예시

from openai import OpenAI
client = OpenAI(base_url="https://api.orcarouter.ai/v1", api_key="sk-orca-...")

tools = [{
    "type": "function",
    "function": {
        "name": "get_weather",
        "parameters": {
            "type": "object",
            "properties": {"city": {"type": "string"}},
            "required": ["city"],
        },
    },
}]

resp = client.chat.completions.create(
    model="openai/gpt-4o-mini",
    messages=[{"role": "user", "content": "Weather in Paris?"}],
    tools=tools,
)
print(resp.choices[0].message.tool_calls)

프로바이더 간 동작

동일한 클라이언트 코드가 채팅 가능한 모든 프로바이더에서 작동합니다 — OrcaRouter는 OpenAI 스타일 tools를 각 업스트림의 네이티브 형태로 적응시킵니다:
  • OpenAI / Grok / DeepSeek: 네이티브 대상 — tools는 와이어에서 OpenAI 형태를 유지
  • Anthropic: OpenAI tools는 Anthropic의 tools + input_schema에 매핑되어 JSON Schema의 propertiesrequired를 보존
  • Gemini: OpenAI tools는 Gemini의 tools[].functionDeclarations에 매핑되어 name / description / parameters가 전달됨

Gemini 예약 함수 이름

Gemini 대상에서 게이트웨이는 세 가지 예약된 function.name 값을 인식하여 커스텀 함수 선언이 아니라 Gemini의 네이티브 내장 도구로 변환합니다:
예약 이름매핑 대상
googleSearchGemini Google Search 그라운딩 (웹 검색 참조)
codeExecutionGemini 내장 코드 실행
urlContextGemini 내장 URL 컨텍스트 도구
이 이름의 함수에는 parameters가 필요 없습니다 — {type: "function", function: {name: "googleSearch"}}를 전달하면 Gemini가 처리합니다. 자신의 커스텀 도구에는 이 내장과 충돌하지 않는 다른 이름을 선택하세요.