Quick Start
Installation
Set your API key
Your first structured call
from promptguard import llm_call
from pydantic import BaseModel
class Sentiment(BaseModel):
label: str
confidence: float
result = llm_call(
model="gpt-4o-mini",
prompt="The product is fantastic and well-made",
schema=Sentiment
)
print(result.data)
# Sentiment(label='positive', confidence=0.95)
Async usage
from promptguard import allm_call
result = await allm_call(
model="gpt-4o",
prompt="Summarize this document...",
schema=Summary
)
Using different schema types
PromptGuard supports Pydantic models, TypedDicts, dataclasses, and raw JSON schemas:
from typing import TypedDict
class Person(TypedDict):
name: str
age: int
result = llm_call(model="gpt-4o", prompt="John is 30", schema=Person)
from dataclasses import dataclass
@dataclass
class Person:
name: str
age: int
result = llm_call(model="gpt-4o", prompt="John is 30", schema=Person)
Running regression tests
See the Testing guide for details.