Best free ai video generator : Synthesia
Best free ai audio generator.(realistic speech in your language) : Elevenlabs
requests library: pip install requests.python
import requests
# Replace with the actual API endpoint and your API key
API_URL = "https://api.convozen.ai/v1/chat"
API_KEY = "your_api_key_here"
def send_message(session_id, message):
"""
Sends a message to the ConvoZen.AI API and returns the AI's response.
"""
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
payload = {
"session_id": session_id, # Unique ID for the conversation
"message": message # User's input message
}
try:
response = requests.post(API_URL, headers=headers, json=payload)
response.raise_for_status() # Raise an error for bad status codes
return response.json() # Return the AI's response
except requests.exceptions.RequestException as e:
print(f"An error occurred: {e}")
return None
def start_conversation():
"""
Starts a conversation with ConvoZen.AI.
"""
session_id = "unique_session_id" # Generate or retrieve a unique session ID
print("Welcome to ConvoZen.AI! Type 'exit' to end the conversation.")
while True:
user_input = input("You: ")
if user_input.lower() == 'exit':
print("Goodbye!")
break
# Send the user's message to the API
response = send_message(session_id, user_input)
# Check if the response contains a valid reply
if response and 'reply' in response:
print(f"ConvoZen.AI: {response['reply']}")
else:
print("ConvoZen.AI: Sorry, I couldn't process your request.")
if __name__ == "__main__":
start_conversation()
Authorization header."your_api_key_here" with your actual API key.session_id is used to maintain the context of the conversation.message field of the payload.json
{
"session_id": "unique_session_id",
"reply": "Hello! How can I assist you today?",
"status": "success"
}
API_URL and API_KEY with the actual values provided by ConvoZen.AI.