Python Client

Flyflow Python Client

The Flyflow Python Client is a library that allows you to interact with the Flyflow API using Python. It provides a convenient way to manage agents, calls, and perform various operations related to the Flyflow platform.

Installation

You can install the Flyflow Python Client using pip:

pip install flyflowclient

Usage

To use the Flyflow Python Client, you need to import the Flyflow class from the flyflowclient module:

from flyflowclient import Flyflow

client = Flyflow()

By default, the client will load the API key from the FLYFLOW_API_KEY environment variable. If you want to provide the API key explicitly, you can pass it as a parameter when creating the client instance:

client = Flyflow(api_key='your_api_key')

The default base URL for the Flyflow API is https://api.flyflow.dev/v1. If you need to use a different base URL, you can pass it as a parameter:

client = Flyflow(base_url='https://custom-api-url.com')

Agent Management

Create an Agent

agent = client.upsert_agent(
    name='Agent Name',
    system_prompt='System prompt',
    initial_message='Initial message',
    llm_model='gpt-4o',
    voice_id='voice_id',
    webhook='https://webhook-url.com',
    tools=[],
    filler_words=True,
    area_code='123'
)

Update an Agent

updated_agent = client.upsert_agent(
    name='Agent Name',
    system_prompt='Updated system prompt'
)

Get an Agent

agent = client.get_agent(agent_id=agent['id'])

Delete an Agent

client.delete_agent(agent_id=agent['id'])

List Agents

agents = client.list_agents(limit=10)

Call Management

Create a Call

call = client.create_call(
    from_number='+1234567890',
    to_number='+9876543210',
    context='Call context'
)

Get a Call

call = client.get_call(call_id=call['id'])

Set Call Context

updated_call = client.set_call_context(
    call_id=call['id'],
    context='Updated call context'
)

List Calls

calls = client.list_calls(limit=10, agent_id=agent['id'])

Error Handling

The Flyflow Python Client raises exceptions for HTTP errors. You can catch and handle these exceptions in your code:

try:
    agent = client.get_agent(agent_id='invalid_id')
except requests.exceptions.HTTPError as e:
    print(f"Error: {e}")

Conclusion

The Flyflow Python Client provides a simple and intuitive way to interact with the Flyflow API. With this library, you can easily manage agents, calls, and perform various operations related to the Flyflow platform. For more detailed information about the available methods and their parameters, please refer to the Flyflow API documentation.