Documentation Index
Fetch the complete documentation index at: https://docs.upsonic.ai/llms.txt
Use this file to discover all available pages before exploring further.
Attributes
The Direct class accepts the following attributes during initialization:
| Attribute | Type | Default | Description |
|---|
model | Union[str, Any, None] | "openai/gpt-4o" | Model identifier or Model instance |
settings | ModelSettings | None | None | Model-specific configuration including temperature, max_tokens, etc. |
profile | ModelProfileSpec | None | None | Model profile configuration for advanced customization |
provider | Union[str, Provider] | None | None | Provider name or Provider instance for custom provider integration |
Configuration Example
from upsonic import Direct, Task
from upsonic.models.settings import ModelSettings
from pydantic import BaseModel
# Define structured output
class ExtractedData(BaseModel):
company_name: str
tax_number: str
total_amount: float
# Create Direct instance with configuration
settings = ModelSettings(temperature=0.1, max_tokens=500)
direct = Direct(
model="anthropic/claude-sonnet-4-5",
settings=settings
)
# Create task with PDF attachment
task = Task(
description="Extract company name, tax number, and total amount from the invoice",
context=["invoice.pdf"],
response_format=ExtractedData
)
# Execute
result = direct.do(task)
print(f"Company: {result.company_name}")
print(f"Tax Number: {result.tax_number}")
print(f"Amount: ${result.total_amount}")