Thinagents

Get Started

Get Started with Thinagents

Install Thinagents

pip install -U thinagents

Set Environment Variables

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

for more information, see litellm_openai

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

for more information, see litellm_anthropic

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

for more information, see litellm_gemini

os.environ["AZURE_API_KEY"] = "your-api-key"
os.environ["AZURE_API_BASE"] = "https://example-endpoint.openai.azure.com"
os.environ["AZURE_API_VERSION"] = "2023-05-15"

for more information, see litellm_azure

Create an Agent

from thinagents import Agent

agent = Agent(
    name="Greeting Agent",
    model="openai/gpt-4o-mini",
)

response = agent.run("Hello, how are you?")
print(response.content)

Agent with tools

from thinagents import Agent

def get_weather(city: str) -> str: 
    return f"The weather in {city} is sunny."

agent = Agent(
    name="Weather Agent",
    model="openai/gpt-4o-mini",
    tools=[get_weather],
)

response = agent.run("What is the weather in Tokyo?")
print(response.content)