API

API 코드 생성기

언어와 작업을 선택하면 OpenAI와 다른 세부 사항을 포함해 Reflection 문서를 따르는 코드를 생성합니다.

Beam-501B-A23B
언어
reasoning_effort
비워 두면 API 기본값이 사용됩니다. 추론은 이 제한에 포함됩니다.

설치 및 키

bash
pip install openai
export REFLECTION_API_KEY="<your API key>"

코드

main.py
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.reflection.ai/openai/v1",
    api_key=os.environ["REFLECTION_API_KEY"],
)

messages = [
    {"role": "user", "content": "Write a short poem about sparse experts."},
]

stream = client.chat.completions.create(
    model="Beam-501B-A23B",
    messages=messages,
    reasoning_effort="medium",
    stream=True,
    stream_options={"include_usage": True},
)

for chunk in stream:
    if not chunk.choices:  # the last chunk carries only usage
        print("\n", chunk.usage)
        continue
    delta = chunk.choices[0].delta
    reasoning = getattr(delta, "reasoning_content", None)
    if reasoning:
        print(reasoning, end="", flush=True)
    if delta.content:
        print(delta.content, end="", flush=True)
추론은 먼저 delta.reasoning_content로 스트리밍된 다음 답변이 delta.content로 스트리밍됩니다. include_usage를 설정하면 토큰 수가 포함된 마지막 청크가 추가됩니다.

매개변수 지원

지원됨
  • model, system, developer, user, assistant 및 tool 역할이 포함된 messages
  • reasoning_effort: low, medium, high, xhigh, max
  • stream 및 stream_options.include_usage
  • tools, tool_choice, parallel_tool_calls
  • response_format: json_object 및 json_schema, strict 포함
  • temperature, top_p, frequency_penalty, presence_penalty, seed, max_completion_tokens
지원되지 않음
  • 이미지, 오디오 및 파일 입력
  • 1이 아닌 n, logprobs, logit_bias
  • user, metadata, audio 및 prediction을 사용하면 오류가 반환됩니다
  • stop은 허용되지만 효과가 없습니다
  • Responses, Embeddings, Images, Audio, Files, Batch 및 Assistants API

처리할 만한 오류

상태 및 코드의미
400 unsupported_value모델에서 허용하지 않는 reasoning_effort 값(예: none 또는 minimal)입니다.
400 missing_required_parameter이전 assistant 메시지가 reasoning_content 없이 전송되었거나 json_schema가 누락되었습니다.
401API 키가 없거나 유효하지 않습니다.
429 rate_limit_exceeded분당 또는 일일 한도에 도달했습니다. Retry-After에 지정된 시간만큼 기다리세요.
503 inference_capacity_unavailable일시적으로 용량이 부족합니다. Retry-After 이후에 재시도하세요.

출처: openai-compatibility · reasoning · tool-calling · structured-outputs · errors