Getting Started
This guide will walk you through the process of setting up and using the Tiptree Platform for the first time.
Prerequisites
Section titled “Prerequisites”Before you begin, ensure you have:
- A Tiptree Platform account (for the managed service) or a self-hosted installation
- API credentials (API key or OAuth client credentials)
- Python 3.8+ or Node.js 14+ for using the client libraries
Installation
Section titled “Installation”Python Client
Section titled “Python Client”Install the Python client library using pip:
pip install tiptree-clientTypeScript/JavaScript Client
Section titled “TypeScript/JavaScript Client”Install the TypeScript client using npm or yarn:
npm install @tiptree/client# oryarn add @tiptree/clientAuthentication
Section titled “Authentication”Using API Keys
Section titled “Using API Keys”# Pythonfrom tiptree.client import TiptreeClient
client = TiptreeClient(api_key="your-api-key")// TypeScriptimport { TiptreeClient } from '@tiptree/client';
const client = new TiptreeClient({ apiKey: 'your-api-key'});Using OAuth
Section titled “Using OAuth”# Pythonfrom tiptree.client import TiptreeClient
client = TiptreeClient( client_id="your-client-id", client_secret="your-client-secret")// TypeScriptimport { TiptreeClient } from '@tiptree/client';
const client = new TiptreeClient({ clientId: 'your-client-id', clientSecret: 'your-client-secret'});Creating Your First Agent
Section titled “Creating Your First Agent”Agents are the core building blocks of the Tiptree Platform. Here’s how to create a simple agent:
# Pythonagent = client.agents.create( name="My First Agent", description="A simple agent for testing", model="gpt-4", system_prompt="You are a helpful assistant that provides concise answers.")
print(f"Agent created with ID: {agent.id}")// TypeScriptconst agent = await client.agents.create({ name: "My First Agent", description: "A simple agent for testing", model: "gpt-4", systemPrompt: "You are a helpful assistant that provides concise answers."});
console.log(`Agent created with ID: ${agent.id}`);Starting a Session
Section titled “Starting a Session”To interact with an agent, you need to create a session:
# Pythonsession = client.sessions.create(agent_id=agent.id)print(f"Session created with ID: {session.id}")// TypeScriptconst session = await client.sessions.create({ agentId: agent.id});
console.log(`Session created with ID: ${session.id}`);Sending Messages
Section titled “Sending Messages”Once you have a session, you can send messages to the agent:
# Pythonresponse = client.messages.send( session_id=session.id, content="What's the capital of France?")
print(f"Agent response: {response.content}")// TypeScriptconst response = await client.messages.send({ sessionId: session.id, content: "What's the capital of France?"});
console.log(`Agent response: ${response.content}`);Retrieving Message History
Section titled “Retrieving Message History”You can retrieve the message history for a session:
# Pythonmessages = client.messages.list(session_id=session.id)for message in messages: print(f"{message.role}: {message.content}")// TypeScriptconst messages = await client.messages.list({ sessionId: session.id});
messages.forEach(message => { console.log(`${message.role}: ${message.content}`);});Using Agent Tools
Section titled “Using Agent Tools”Agents can be configured with tools to perform actions:
# Pythonagent_with_tools = client.agents.create( name="Weather Agent", description="An agent that can check the weather", model="gpt-4", system_prompt="You are a helpful assistant that can check the weather.", tools=[ { "name": "get_weather", "description": "Get the current weather for a location", "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "The city and state, e.g. San Francisco, CA" } }, "required": ["location"] } } ])// TypeScriptconst agentWithTools = await client.agents.create({ name: "Weather Agent", description: "An agent that can check the weather", model: "gpt-4", systemPrompt: "You are a helpful assistant that can check the weather.", tools: [ { name: "get_weather", description: "Get the current weather for a location", parameters: { type: "object", properties: { location: { type: "string", description: "The city and state, e.g. San Francisco, CA" } }, required: ["location"] } } ]});Next Steps
Section titled “Next Steps”Now that you’ve created your first agent and interacted with it, you can:
- Explore the API Reference for more advanced features
- Learn about Agent Configuration options
- Understand Error Handling for robust applications