Tensormesh

Tensormesh

개요 (Overview)

속성 내용
설명 Tensormesh는 OpenAI 호환 API를 갖춘 서버리스 AI 추론을 제공해요.
LiteLLM 제공자 라우트 tensormesh/
제공자 문서 링크 Tensormesh Documentation
기본 Base URL https://serverless.tensormesh.ai/v1
지원 작업 /chat/completions, /completions, /responses, 그리고 LiteLLM의 Anthropic Messages 어댑터를 통한 /messages

API 키 (API Key)

환경 변수

import os

os.environ["TENSORMESH_INFERENCE_API_KEY"] = "your-api-key"

모델 (Models)

서버리스 카탈로그에서 사용 가능한 모델 목록을 확인할 수 있어요:

curl https://serverless.tensormesh.ai/v1/models

카탈로그 id를 tensormesh/ 라우트와 함께 사용해요. 예: tensormesh/openai/gpt-oss-120b, tensormesh/MiniMaxAI/MiniMax-M2.5, 또는 tensormesh/deepseek-ai/DeepSeek-V4-Flash.

사용법 - LiteLLM Python SDK

Chat Completions

Tensormesh Chat Completion

import os
from litellm import completion

os.environ["TENSORMESH_INFERENCE_API_KEY"] = "your-api-key"

response = completion(
    model="tensormesh/<your-model-name>",
    messages=[{"role": "user", "content": "Say hello in one sentence."}],
)

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

스트리밍 (Streaming)

Tensormesh 스트리밍 Chat Completion

import os
from litellm import completion

os.environ["TENSORMESH_INFERENCE_API_KEY"] = "your-api-key"

response = completion(
    model="tensormesh/<your-model-name>",
    messages=[{"role": "user", "content": "Write a short poem about inference."}],
    stream=True,
)

for chunk in response:
    print(chunk)

도구 호출 (Tool Calling)

Tensormesh 도구 호출

import os
from litellm import completion

os.environ["TENSORMESH_INFERENCE_API_KEY"] = "your-api-key"

tools = [
    {
        "type": "function",
        "function": {
            "name": "get_weather",
            "description": "Get the current weather for a city",
            "parameters": {
                "type": "object",
                "properties": {"city": {"type": "string", "description": "City name"}},
                "required": ["city"],
            },
        },
    }
]

response = completion(
    model="tensormesh/<your-model-name>",
    messages=[{"role": "user", "content": "What is the weather in San Francisco?"}],
    tools=tools,
    tool_choice="auto",
)

print(response.choices[0].message.tool_calls)

각 도구 함수는 비어 있지 않은 description을 포함해야 해요. Tensormesh는 description이 없는 도구 정의를 거부해요.

추론 (Reasoning)

Tensormesh 추론 모델(예: DeepSeek-V4-Flash, Qwen3.5-397B, Qwen3.6-27B, GLM-5.1, MiniMax-M2.5, Kimi-K2.6, gpt-oss 모델들)은 vLLM 채팅 템플릿 제어를 통해 thinking 모드를 노출해요. thinking 토글(thinking 또는 enable_thinking)을 reasoning_effort와 짝지어 extra_body로 전달하면 돼요. 모델은 사고 사슬을 reasoning_content로 반환해요.

Tensormesh 추론

import os
from litellm import completion

os.environ["TENSORMESH_INFERENCE_API_KEY"] = "your-api-key"

response = completion(
    model="tensormesh/deepseek-ai/DeepSeek-V4-Flash",
    messages=[{"role": "user", "content": "If a train travels 60 miles in 1.5 hours, what is its average speed?"}],
    extra_body={"chat_template_kwargs": {"thinking": True, "reasoning_effort": "high"}},
)

print(response.choices[0].message.reasoning_content)
print(response.choices[0].message.content)

텍스트 Completion (Text Completions)

Tensormesh Text Completion

import os
from litellm import text_completion

os.environ["TENSORMESH_INFERENCE_API_KEY"] = "your-api-key"

response = text_completion(
    model="tensormesh/<your-model-name>",
    prompt="Complete this sentence: Fast inference matters because",
    max_tokens=32,
)

print(response.choices[0].text)

Responses API

Tensormesh Responses API

import os
import litellm

os.environ["TENSORMESH_INFERENCE_API_KEY"] = "your-api-key"

response = litellm.responses(
    model="tensormesh/<your-model-name>",
    input="Say hello in one sentence.",
)

print(response)

사용법 - LiteLLM Proxy

LiteLLM Proxy 설정에 Tensormesh를 추가해 주세요:

config.yaml

model_list:
  - model_name: tensormesh-chat
    litellm_params:
      model: tensormesh/<your-model-name>
      api_key: os.environ/TENSORMESH_INFERENCE_API_KEY

general_settings:
  master_key: os.environ/LITELLM_MASTER_KEY

프록시를 시작해 주세요:

export TENSORMESH_INFERENCE_API_KEY="your-api-key"
export LITELLM_MASTER_KEY="sk-loc...mesh"
litellm --config config.yaml --port 4000

# RUNNING on http://0.0.0.0:4000

LiteLLM Proxy에 대한 요청은 Authorization: Bearer $LITEL...KEY에 프록시 키를 사용해야 해요. TENSORMESH_INFERENCE_API_KEY는 LiteLLM이 업스트림 Tensormesh를 호출할 때만 사용돼요.

기본 시작 확인은 /health/liveliness 또는 /health/readiness를 사용해요. /health 엔드포인트는 인증이 필요하며 모델 체크를 실행할 수 있어요.

  • OpenAI SDK
  • cURL

Proxy를 통한 Tensormesh - OpenAI SDK

from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:4000",
    api_key="sk-loc...mesh",
)

response = client.chat.completions.create(
    model="tensormesh-chat",
    messages=[{"role": "user", "content": "hello from litellm"}],
)

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

Proxy를 통한 Tensormesh - cURL

curl http://localhost:4000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $LITEL..._KEY" \
  -d '{
    "model": "tensormesh-chat",
    "messages": [{"role": "user", "content": "hello from litellm"}]
  }'

Anthropic Messages 호환성

LiteLLM은 Anthropic Messages 형태의 요청을 Tensormesh 채팅 completions로 변환할 수 있어요. Python SDK에서 Anthropic Messages 퍼사드를 사용하세요:

LiteLLM SDK를 통한 Anthropic Messages

import os
import litellm

os.environ["TENSORMESH_INFERENCE_API_KEY"] = "your-api-key"

response = litellm.anthropic.messages.create(
    model="tensormesh/<your-model-name>",
    max_tokens=128,
    messages=[{"role": "user", "content": "Say hello in one sentence."}],
)

print(response["content"][0]["text"])

HTTP 클라이언트의 경우, LiteLLM Proxy는 Anthropic 호환 /v1/messages 엔드포인트를 노출하고 업스트림 요청을 Tensormesh 채팅 completions로 라우팅해요. 요청 본문의 model을 프록시 model_name으로 설정하세요.

LiteLLM Proxy를 통한 Anthropic Messages

curl http://localhost:4000/v1/messages \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $LITEL..._KEY" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "tensormesh-chat",
    "max_tokens": 128,
    "messages": [{"role": "user", "content": "Say hello in one sentence."}]
  }'

SDK 퍼사드와 Proxy /v1/messages 엔드포인트 모두 LiteLLM의 Anthropic Messages 어댑터를 사용해요. Tensormesh는 업스트림으로 OpenAI 호환 채팅 completion 요청을 받아요.

비용 추적 (Cost Tracking)

Tensormesh 서버리스 모델은 LiteLLM 모델 비용 맵에 등록되어 있어, LiteLLM이 요청별 지출을 자동으로 계산해요. 프록시에서는 비용이 x-litellm-response-cost 응답 헤더로 반환되고 지출 로그에 기록돼요. 캐시된 입력 토큰은 0으로 청구돼요.

공통 파라미터 (Common Parameters)

다음은 시작하기 위한 공통 파라미터예요. 추가 파라미터는 모델에 따라 달라지며 대상 Tensormesh 모델로 검증해야 해요.

엔드포인트 공통 파라미터
/chat/completions messages, max_tokens, max_completion_tokens, temperature, top_p, stream, stop, tools, tool_choice, response_format, extra_body, extra_headers
/completions prompt, max_tokens, temperature, top_p, stream, stop
/responses input, max_output_tokens, temperature, top_p, stream, tools, tool_choice, text, extra_headers
/messages messages, max_tokens, temperature, top_p, stream, tools, tool_choice, extra_headers

채팅 completions의 경우 LiteLLM은 max_completion_tokens을 받아 Tensormesh에는 max_tokens으로 매핑해요.

참고 사항 (Notes)

  • 직접 LiteLLM SDK 호출에는 model="tensormesh/<your-model-name>"를 사용해요.
  • 기본 서버리스 base URL은 https://serverless.tensormesh.ai/v1이에요.
  • 추론 제어(thinking/enable_thinkingreasoning_effort)는 extra_body.chat_template_kwargs를 통해 전달되며 추론 지원 모델에서 적용돼요.

출처: 문서

본문

더 알아보기 (Learn more)