carter-py
Prerequisites
In order to use carter-py you'll need to sign up to sign up to CarterAPI and create an agent. CarterAPI has excellent documentation.
Installation
pip install carter-py
The Carter Object
The main component of carter-py is the Carter class. This class provides a set of methods to interact with your carter agent.
from carterpy import Carter
# Replace YOUR_API_KEY with your actual API key
carter = Carter("YOUR_API_KEY")
# Send a message to the API
response = carter.say("Hello, world!", "player123")
# Print the response text
print(response.output_text)Pass in the apiKey of your specific agent - remember to keep this secret while developing and in production as this will allow anyone access to your agent.
Async
carter-py is compatible with asynchronous code through importing the async version of the class.
Speak
When using any of the following methods, the output audio will not be returned by default as this currently introduces significant latency on the API end. If you want to receive the audio you have two options. You can set the speak parameter to Truewhen creating the Carter object, or you can set it to Truewhen calling the method. When calling a function carter-py will first check if the speak parameter has been overridden in the function call, if it hasn't, it will use the class default.
Documentation on say() is included in further sections.
Last updated