Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Togethercomputer Together python Model Types

From Leeroopedia
Knowledge Sources
Domains Model_Management, Type_System
Last Updated 2026-02-15 16:00 GMT

Overview

Concrete type definitions for model metadata and upload operations provided by the Together Python SDK.

Description

This module defines the Pydantic models for the models API: ModelType enum (chat, language, code, image, embedding, moderation, rerank, audio, transcribe, video), ModelObject (model metadata with id, type, pricing, context_length), PricingObject (input/output/hourly/base/finetune pricing), ModelUploadRequest (upload parameters), and ModelUploadResponse (upload job result with smart API response parsing).

Usage

Import these types when you need to type-hint model-related data or inspect model metadata objects.

Code Reference

Source Location

Signature

class ModelType(str, Enum):
    CHAT = "chat"; LANGUAGE = "language"; CODE = "code"
    IMAGE = "image"; EMBEDDING = "embedding"; MODERATION = "moderation"
    RERANK = "rerank"; AUDIO = "audio"; TRANSCRIBE = "transcribe"; VIDEO = "video"

class PricingObject(BaseModel):
    input: float | None = None
    output: float | None = None
    hourly: float | None = None
    base: float | None = None
    finetune: float | None = None

class ModelObject(BaseModel):
    id: str
    object: Literal[ObjectType.Model]
    type: ModelType | None = None
    display_name: str | None = None
    organization: str | None = None
    context_length: int | None = None
    pricing: PricingObject

class ModelUploadResponse(BaseModel):
    job_id: Optional[str] = None
    model_name: Optional[str] = None
    model_id: Optional[str] = None
    model_source: Optional[str] = None
    message: str

Import

from together.types.models import ModelObject, ModelType, ModelUploadResponse, PricingObject

I/O Contract

Inputs

Name Type Required Description
(constructed from API responses) Dict[str, Any] Yes API JSON data parsed into typed models

Outputs

Name Type Description
ModelObject Pydantic Model Model metadata with id, type, pricing, context_length
ModelUploadResponse Pydantic Model Upload job result with job_id, model_name, message
PricingObject Pydantic Model Input/output/hourly pricing per token/hour

Usage Examples

from together import Together

client = Together()

models = client.models.list()
for model in models:
    # model is ModelObject
    print(f"{model.id} ({model.type})")
    print(f"  Context: {model.context_length}")
    print(f"  Price: ${model.pricing.input}/M input, ${model.pricing.output}/M output")

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment