본문으로 건너뛰기
문서 탐색: 오픈 모델 / 추가 추론 클라이언트

추가 추론 클라이언트

RightNow AI오픈 모델추가 추론 클라이언트 업데이트

이 페이지의 내용

모델 허브의 추론 클라이언트는 Python용 huggingface_hub와(과) JavaScript용 @huggingface/inference 두 가지이며, 둘 다 chat 호환 기본 URL을 받으므로 지금 오픈 모델 API를 호출합니다.

hub clients
Text
Illustration of the address each model hub client takes.

Both clients take an address. The Python client takes base_url, with the base URL that ends in /v1. The JavaScript client takes endpointUrl, with the host: the client adds /v1/chat/completions itself. Naming the open models as a provider does not resolve: they are not a registered inference provider in the model hub.

Python

Shell
pip install "huggingface_hub>=1.0"
export RIGHTNOW_API_KEY="rp_your_key_here"
Python
import os
from huggingface_hub import InferenceClient

client = InferenceClient(
    base_url="https://api.rightnowai.co/v1",
    api_key=os.environ["RIGHTNOW_API_KEY"],
)

prompt = "Write a TypeScript retry helper."
completion = client.chat.completions.create(
    model="MODEL_ID",
    messages=[{"role": "user", "content": prompt}],
    max_tokens=16384,
)

print(completion.choices[0].message.content)

MODEL_ID을(를) 실시간 목록에 있는 ID로 바꾸세요. 이 클라이언트는 보통 모델 허브 저장소 ID를 받습니다. 이 페이지의 기본 URL 형식에서는 오픈 모델 API와 직접 통신하므로 오픈 모델의 ID를 넘깁니다.

스트리밍은 stream=True을(를) 붙인 같은 호출이며, chunk.choices[0].delta.content를 읽고 choices가 없는 사용량 프레임은 건너뜁니다.

JavaScript

키를 token으로 넘기고 endpointUrl를 클라이언트 옵션에 넘기세요. 호스트는 /v1이(가) 있어도 없어도 동작합니다.

Shell
npm install @huggingface/inference
export RIGHTNOW_API_KEY="rp_your_key_here"
Text
import { InferenceClient } from "@huggingface/inference";

const token = process.env.RIGHTNOW_API_KEY;
const client = new InferenceClient(token, {
  endpointUrl: "https://api.rightnowai.co",
});

const prompt = "Write a TypeScript retry helper.";
const completion = await client.chatCompletion({
  model: "MODEL_ID",
  messages: [{ role: "user", content: prompt }],
  max_tokens: 16384,
});

console.log(completion.choices[0].message.content);

chatCompletionStream은(는) 같은 인자를 받고 델타를 돌려줍니다.

Warning

endpointUrl를 명시적인 외부 제공자의 provider와(과) 함께 쓰지 마세요. 클라이언트는 그 조합을 Cannot use endpointUrl with a third-party provider 메시지로 거부합니다. endpointUrl만 넘기세요.

모델 기능

동작하는 JSON 조각은 구조화된 출력에 있습니다. 모델이 JSON 출력을 위해 특정 reasoning_effort를 필요로 하면, 그 필드를 생략했을 때 게이트웨이가 적용합니다. 요청이 지정하지 않은 강도를 게이트웨이가 고를 때는 응답 헤더 X-RunInfra-Reasoning-Effort-Applied가 적용된 값을 담습니다.

일시적으로 일시 중지된 모델은 모델 목록과 그 오픈 모델 페이지에 표시됩니다.

모델의 추론이 도착하는 곳

각자의 페이지에서 설명하는 추론 모델은 답하기 전에 생각합니다. 그 텍스트는 delta.reasoning로 스트리밍되어 message.reasoning에 나타나며, content에는 절대 나타나지 않습니다.

response.json
JSON
{
  "id": "chatcmpl-example",
  "object": "chat.completion",
  "model": "glm-5-3",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "reasoning": "The user wants a retry helper. I should use exponential backoff...",
        "content": "export async function retry<T>(fn: () => Promise<T>, attempts = 3) { ... }"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": { "prompt_tokens": 14, "completion_tokens": 892, "total_tokens": 906 }
}

이 예시의 ID, 텍스트, 토큰 수는 설명을 위한 것입니다.

어떤 클라이언트를 쓸지

이미 모델 허브 생태계 안에 있다면 이 페이지의 클라이언트가 그대로 동작하고 여기서 나중에 바뀌는 것은 없습니다. 아니라면 chat API 클라이언트를 쓰세요. 가장 짧은 길이며 이 문서의 나머지도 그것을 전제로 합니다. 호환 클라이언트를 참고하세요.

어느 쪽이든 이 호출은 오픈 모델 API에 대한 다른 호출과 똑같이 청구됩니다. 가격과 크레딧 및 속도 제한을 참고하세요.