### Install Agent.ai Python SDK Source: https://github.com/onstartups/python_sdk/blob/main/examples/README.md Instructions for installing the agentai Python library using pip. Supports installation from PyPI or directly from source. ```bash pip install agentai ``` ```bash cd /path/to/python_sdk pip install -e . ``` -------------------------------- ### Basic Chat with Agent.ai SDK Source: https://github.com/onstartups/python_sdk/blob/main/examples/README.md A simple Python example showing how to initialize the AgentAiClient and perform a basic chat query. It demonstrates checking the response status and printing the results. ```python from agentai import AgentAiClient client = AgentAiClient() # Uses AGENTAI_API_KEY env var response = client.chat("What is machine learning?") if response['status'] == 200: print(response['results']) ``` -------------------------------- ### Specify LLM Models for Chat Source: https://github.com/onstartups/python_sdk/blob/main/examples/README.md Demonstrates how to select different Large Language Models (LLMs) for chat interactions using the `client.chat()` method. Includes examples for OpenAI, Anthropic, Google, and Meta models. ```python # OpenAI client.chat("Hello", model="gpt4o") # GPT-4o (default) client.chat("Hello", model="gpt4o-mini") # GPT-4o Mini # Anthropic client.chat("Hello", model="claude-sonnet") client.chat("Hello", model="claude-haiku") # Google client.chat("Hello", model="gemini-pro") client.chat("Hello", model="gemini-flash") # Meta client.chat("Hello", model="llama-70b") client.chat("Hello", model="llama-8b") # Others client.chat("Hello", model="deepseek") ``` -------------------------------- ### News Search with Agent.ai SDK Source: https://github.com/onstartups/python_sdk/blob/main/examples/README.md Example of using the AgentAiClient to search Google News for specific topics within a given date range. It iterates through the search results and prints the titles of the articles. ```python response = client.get_google_news("AI news", date_range="7d") for article in response['results'].get('organic_results', []): print(f"- {article['title']}") ``` -------------------------------- ### Research Assistant Example with Python SDK Source: https://github.com/onstartups/python_sdk/blob/main/llm.txt An example demonstrating how to build a research assistant. It searches the web, extracts text from the top result, and then uses an LLM to summarize the content. Requires the `AgentAiClient` and handles potential errors in API calls. ```python from agentai import AgentAiClient client = AgentAiClient() def research_topic(topic): # Search the web search_results = client.search_web(topic, num_results=5) # Get content from top result if search_results['status'] == 200 and search_results['results']: top_url = search_results['results'][0]['link'] content = client.grab_web_text(top_url) # Summarize with LLM if content['status'] == 200: summary = client.chat( f"Summarize this article:\n\n{content['results'][:5000]}", model="gpt4o" ) return summary['results'] return None print(research_topic("latest developments in quantum computing")) ``` -------------------------------- ### Content Generator Example with Python SDK Source: https://github.com/onstartups/python_sdk/blob/main/llm.txt An example demonstrating content generation for social media. It uses an LLM to write a post and then generates a relevant image using an image generation model. The output includes both the text and the URL of the generated image. ```python def generate_social_post(topic): # Generate text text_response = client.chat( f"Write a short, engaging social media post about {topic}. Include hashtags.", model="gpt4o" ) # Generate image image_response = client.generate_image( f"Professional image representing {topic}", model="DALL-E 3", aspect_ratio="1:1" ) return { "text": text_response['results'], "image_url": image_response['results']['images'][0]['url'] } ``` -------------------------------- ### Set Agent.ai API Key Source: https://github.com/onstartups/python_sdk/blob/main/examples/README.md Demonstrates how to set the AGENTAI_API_KEY environment variable, which is required for authenticating with the Agent.ai service. The API key can be obtained from the Agent.ai user settings. ```bash export AGENTAI_API_KEY="your_api_key_here" ``` -------------------------------- ### Social Media Monitor Example with Python SDK Source: https://github.com/onstartups/python_sdk/blob/main/llm.txt An example function to monitor a brand across different social media platforms and news sources. It fetches Google News, recent tweets, and LinkedIn activity for the specified brand. Results are aggregated into a dictionary. ```python def monitor_brand(brand_name): # Get news news = client.get_google_news(brand_name, date_range="1d") # Get tweets tweets = client.get_recent_tweets(brand_name, count=10) # Get LinkedIn activity linkedin = client.get_linkedin_activity(f"company/{brand_name}", num_posts=5) return { "news": news['results'], "tweets": tweets['results'], "linkedin": linkedin['results'] } ``` -------------------------------- ### File Conversion Options with AgentAiClient Source: https://github.com/onstartups/python_sdk/blob/main/README.md Demonstrates how to check available file conversion formats for a given input format using the AgentAiClient. The example queries for conversion options for PDF files and prints the results. ```python # Check available conversion formats response = client.get_convert_options("pdf") print(f"PDF can be converted to: {response['results']}") ``` -------------------------------- ### Text to Speech Conversion with AgentAiClient Source: https://github.com/onstartups/python_sdk/blob/main/README.md Shows how to convert text into speech using the AgentAiClient. The example demonstrates providing the text and selecting a voice for the audio output, and then printing the URL of the generated audio file. ```python response = client.text_to_audio( text="Hello, welcome to agent.ai!", voice="alloy" ) if response['status'] == 200: print(f"Audio URL: {response['results']}") ``` -------------------------------- ### Web Scraping with AgentAiClient Source: https://github.com/onstartups/python_sdk/blob/main/README.md Provides examples for scraping text content and taking screenshots of webpages using the AgentAiClient. It shows how to specify whether to capture the full page for screenshots. ```python # Get text from a webpage response = client.grab_web_text("https://example.com") if response['status'] == 200: print(response['results']) # Take a screenshot response = client.grab_web_screenshot("https://example.com", full_page=True) if response['status'] == 200: print(f"Screenshot URL: {response['results']}") ``` -------------------------------- ### Web Scraping with Agent.ai SDK Source: https://github.com/onstartups/python_sdk/blob/main/examples/README.md Python code snippet to scrape text content from a given URL using the `grab_web_text` function of the AgentAiClient. The extracted text is then printed to the console. ```python response = client.grab_web_text("https://example.com") print(response['results']) ``` -------------------------------- ### Get Company Info API Source: https://context7.com/onstartups/python_sdk/llms.txt Get comprehensive company intelligence from a domain including name, description, industry, employee count, and other business metadata. ```APIDOC ## POST /get_company_info ### Description Get comprehensive company intelligence from a domain including name, description, industry, employee count, and other business metadata. ### Method POST ### Endpoint /get_company_info ### Parameters #### Query Parameters - **domain** (string) - Required - The domain name of the company (e.g., 'hubspot.com'). ### Request Example ```python { "domain": "hubspot.com" } ``` ### Response #### Success Response (200) - **status** (integer) - The status code of the response. - **results** (object) - An object containing company information (e.g., name, description, industry, employee count). #### Response Example ```json { "status": 200, "results": { "name": "HubSpot", "description": "HubSpot is a leading CRM platform...", "category": { "industry": "Software" }, "metrics": { "employeesRange": "5001-10000" } } } ``` ``` -------------------------------- ### YouTube Interactions with AgentAiClient Source: https://github.com/onstartups/python_sdk/blob/main/README.md Demonstrates how to interact with YouTube data using the AgentAiClient. This includes fetching video transcripts, searching for videos, and retrieving channel information. The examples show how to handle the results returned by the API. ```python # Get video transcript response = client.get_youtube_transcript("https://www.youtube.com/watch?v=dQw4w9WgXcQ") print(response['results']) # Search YouTube response = client.search_youtube("python tutorials", max_results=5) for video in response['results']: print(video['title']) # Get channel info response = client.get_youtube_channel("https://www.youtube.com/@PythonTutorials") print(response['results']) ``` -------------------------------- ### Image Generation with AgentAiClient Source: https://github.com/onstartups/python_sdk/blob/main/README.md Explains how to generate images based on text prompts using the AgentAiClient. This includes specifying the image generation model, style, and aspect ratio. The example shows how to retrieve the URL of the generated image. ```python response = client.generate_image( prompt="A futuristic city with flying cars", model="DALL-E 3", # or "Stable Diffusion" style="digital art", aspect_ratio="16:9" # Options: 1:1, 16:9, 9:16, 4:3, 3:4 ) if response['status'] == 200: print(f"Image URL: {response['results']['images'][0]['url']}") ``` -------------------------------- ### News and Web Search with AgentAiClient Source: https://github.com/onstartups/python_sdk/blob/main/README.md Shows how to perform news searches and general web searches using the AgentAiClient. Examples include filtering Google News results by date range and location, and specifying the number of results for a web search. ```python # Google News response = client.get_google_news( query="artificial intelligence", date_range="7d", # Options: 1d, 7d, 30d, 1y location="US" ) for article in response['results'].get('organic_results', []): print(f"- {article['title']}") # Web Search response = client.search_web("best python libraries 2024", num_results=10) print(response['results']) ``` -------------------------------- ### Extract YouTube Transcripts with Agent.ai SDK Source: https://context7.com/onstartups/python_sdk/llms.txt Demonstrates extracting the full transcript from a YouTube video using `get_youtube_transcript`. The example also shows how to summarize the extracted transcript using the chat functionality. ```python from agentai import AgentAiClient client = AgentAiClient() response = client.get_youtube_transcript("https://www.youtube.com/watch?v=dQw4w9WgXcQ") if response['status'] == 200: transcript = response['results'] print(f"Transcript (first 200 chars): {transcript[:200]}...") # Summarize the transcript using chat summary = client.chat( prompt=f"Summarize this video transcript:\n\n{transcript[:5000]}", model="gpt4o" ) print(f"\nSummary: {summary['results']}") else: print(f"Error: {response['error']}") ``` -------------------------------- ### Image Generation with Agent.ai SDK Source: https://github.com/onstartups/python_sdk/blob/main/examples/README.md Python code to generate an image based on a text prompt using the `generate_image` function. It specifies the model (e.g., DALL-E 3) and prints the URL of the generated image. ```python response = client.generate_image("A sunset over mountains", model="DALL-E 3") print(response['results']['images'][0]['url']) ``` -------------------------------- ### Chat with LLM Models using Agent.ai SDK Source: https://context7.com/onstartups/python_sdk/llms.txt Shows how to perform chat interactions with various LLM models supported by the Agent.ai SDK. Includes examples for using the default model and specifying a particular model for the response. ```python from agentai import AgentAiClient client = AgentAiClient() # Simple chat with default model (gpt4o) response = client.chat("Explain quantum computing in simple terms") if response['status'] == 200: print(response['results']) else: print(f"Error: {response['error']}") # Output: Quantum computing uses quantum bits (qubits) that can exist in multiple # states simultaneously, enabling parallel processing of complex calculations... # Chat with specific model response = client.chat( prompt="Write a haiku about coding", model="claude-sonnet" # Options: gpt4o, gpt4o-mini, claude-sonnet, claude-haiku, # gemini-pro, gemini-flash, llama-70b, llama-8b, deepseek ) print(response['results']) # Output: # Silent keystrokes fall # Logic flows through circuits deep # Code becomes alive ``` -------------------------------- ### Chat with LLMs using AgentAiClient Source: https://github.com/onstartups/python_sdk/blob/main/README.md Shows how to interact with Large Language Models (LLMs) using the AgentAiClient. Includes examples for a simple chat and specifying a particular LLM model for the response. Error handling for the API response is also demonstrated. ```python from agentai import AgentAiClient client = AgentAiClient() # Simple chat response = client.chat("Explain quantum computing in simple terms") if response['status'] == 200: print(response['results']) # Specify a model response = client.chat( prompt="Write a haiku about coding", model="claude-sonnet" # Options: gpt4o, gpt4o-mini, claude-sonnet, claude-haiku, # gemini-pro, gemini-flash, llama-70b, llama-8b, deepseek ) if response['status'] == 200: print(response['results']) ``` -------------------------------- ### Get YouTube Channel API Source: https://context7.com/onstartups/python_sdk/llms.txt Retrieve information about a YouTube channel, including subscriber count, video count, and channel description. ```APIDOC ## POST /get_youtube_channel ### Description Retrieve information about a YouTube channel including subscriber count, video count, and channel description. ### Method POST ### Endpoint /get_youtube_channel ### Parameters #### Query Parameters - **channel_url** (string) - Required - The URL of the YouTube channel. ### Request Example ```python { "channel_url": "https://www.youtube.com/@PythonTutorials" } ``` ### Response #### Success Response (200) - **status** (integer) - The status code of the response. - **results** (object) - An object containing channel information (e.g., subscriber count, video count, description). #### Response Example ```json { "status": 200, "results": { "subscriber_count": 1000000, "video_count": 500, "description": "Official channel for Python tutorials." } } ``` ``` -------------------------------- ### Get Google News API Source: https://context7.com/onstartups/python_sdk/llms.txt Fetch Google News articles for any query with configurable date ranges and location filtering. ```APIDOC ## POST /get_google_news ### Description Fetch Google News articles for any query with configurable date ranges and location filtering. ### Method POST ### Endpoint /get_google_news ### Parameters #### Query Parameters - **query** (string) - Required - The search query for news articles. - **date_range** (string) - Optional - The time range for articles (e.g., '1d', '7d', '30d', '1y'). Defaults to '7d'. - **location** (string) - Optional - The location filter for news articles (e.g., 'US'). ### Request Example ```python { "query": "artificial intelligence", "date_range": "7d", "location": "US" } ``` ### Response #### Success Response (200) - **status** (integer) - The status code of the response. - **results** (object) - An object containing news articles, typically under 'organic_results'. Each article has 'title' and 'link'. #### Response Example ```json { "status": 200, "results": { "organic_results": [ { "title": "OpenAI Announces New AI Model With Enhanced Reasoning", "link": "https://techcrunch.com/..." } ] } } ``` ``` -------------------------------- ### Company Intelligence Gathering with AgentAiClient Source: https://github.com/onstartups/python_sdk/blob/main/README.md Demonstrates how to retrieve company-specific information using a company's domain name with the AgentAiClient. The example shows how to access details like company name, industry, and employee range from the API response. ```python # Get company info from domain response = client.get_company_info("hubspot.com") if response['status'] == 200: company = response['results'] print(f"Name: {company.get('name')}") print(f"Industry: {company.get('category', {}).get('industry')}") print(f"Employees: {company.get('metrics', {}).get('employeesRange')}") ``` -------------------------------- ### Get YouTube Channel Info with Agent.ai Python SDK Source: https://github.com/onstartups/python_sdk/blob/main/llm.txt Fetches information about a YouTube channel using its URL with `client.get_youtube_channel`. Returns a dictionary containing channel data. ```python response = client.get_youtube_channel("https://www.youtube.com/@ChannelName") print(response['results']) # Channel data dict ``` -------------------------------- ### Get Instagram Profile Information with Python SDK Source: https://github.com/onstartups/python_sdk/blob/main/llm.txt Fetches Instagram profile information using the user's handle. Returns profile data. ```python response = client.get_instagram_profile("instagram") print(response['results']) ``` -------------------------------- ### Agent.ai SDK Error Handling Source: https://github.com/onstartups/python_sdk/blob/main/examples/README.md Illustrates a robust error handling pattern for Agent.ai SDK responses. It checks the 'status' code to differentiate between successful requests, authentication errors, and connection issues, providing specific feedback for each case. ```python response = client.chat("Hello") if response['status'] == 200: # Success print(response['results']) print(response['metadata']) # Optional metadata elif response['status'] == 403: print("Authentication error - check your API key") elif response['status'] is None: print(f"Connection error: {response['error']}") else: print(f"Error {response['status']}: {response['error']}") ``` -------------------------------- ### Social Media Data Retrieval with AgentAiClient Source: https://github.com/onstartups/python_sdk/blob/main/README.md Illustrates how to fetch data from various social media platforms using the AgentAiClient. Supported platforms include LinkedIn, Twitter/X, Bluesky, and Instagram. Examples show retrieving profiles, posts, and tweets. ```python # LinkedIn response = client.get_linkedin_profile("company/hubspot") print(response['results']) # Twitter/X response = client.get_recent_tweets("elonmusk", count=5) for tweet in response['results']: print(tweet['text']) # Bluesky response = client.get_bluesky_posts("user.bsky.social", count=10) print(response['results']) # Instagram response = client.get_instagram_profile("instagram") print(response['results']) ``` -------------------------------- ### Get Bluesky Posts with Python SDK Source: https://github.com/onstartups/python_sdk/blob/main/llm.txt Retrieves recent posts from a Bluesky user. Accepts the user's handle and the number of posts. Returns a list of posts. ```python response = client.get_bluesky_posts("user.bsky.social", count=5) print(response['results']) ``` -------------------------------- ### Get Conversion Options with Python SDK Source: https://github.com/onstartups/python_sdk/blob/main/llm.txt Retrieves a list of available conversion formats for a given file extension. This function helps determine what formats a file can be converted into. The output is a list of strings representing target formats. ```python response = client.get_convert_options("pdf") print(f"PDF can be converted to: {response['results']}") # Output: ['txt', 'docx', 'html', ...] ``` -------------------------------- ### Make REST Calls with Python SDK Source: https://github.com/onstartups/python_sdk/blob/main/llm.txt Demonstrates how to perform GET and POST requests using the client.rest_call method. Supports custom headers and request bodies for POST requests. The response is expected to be a dictionary containing a 'results' key. ```python response = client.rest_call("https://api.example.com/data") response = client.rest_call( url="https://api.example.com/create", method="POST", headers={"Authorization": "Bearer token123"}, body={"name": "Test", "value": 42} ) print(response['results']) ``` -------------------------------- ### Make REST API Calls using Python Source: https://context7.com/onstartups/python_sdk/llms.txt Enables arbitrary REST API calls through Agent.ai, facilitating integration with external services. Supports GET, POST, and other HTTP methods, including custom headers and bodies. Requires AgentAiClient. ```python from agentai import AgentAiClient client = AgentAiClient() # GET request response = client.rest_call("https://api.example.com/data") if response['status'] == 200: print(f"GET response: {response['results']}") # POST request with headers and body response = client.rest_call( url="https://api.example.com/create", method="POST", headers={"X-Custom-Header": "value", "Authorization": "Bearer token123"}, body={"name": "Test Item", "value": 42} ) if response['status'] == 200: print(f"POST response: {response['results']}") else: print(f"Error: {response['error']}") ``` -------------------------------- ### Get YouTube Channel Info with Python Source: https://context7.com/onstartups/python_sdk/llms.txt Retrieves detailed information about a YouTube channel, including subscriber count, video count, and description, given a channel URL. Uses the agentai library. Processes the response by printing channel data if successful, or an error message otherwise. ```python from agentai import AgentAiClient client = AgentAiClient() response = client.get_youtube_channel("https://www.youtube.com/@PythonTutorials") if response['status'] == 200: channel = response['results'] print(f"Channel data: {channel}") else: print(f"Error: {response['error']}") ``` -------------------------------- ### Get LinkedIn Activity API Source: https://context7.com/onstartups/python_sdk/llms.txt Get recent LinkedIn posts and activity from a profile for monitoring professional content. ```APIDOC ## POST /get_linkedin_activity ### Description Get recent LinkedIn posts and activity from a profile for monitoring professional content. ### Method POST ### Endpoint /get_linkedin_activity ### Parameters #### Query Parameters - **profile_url_or_id** (string) - Required - The URL or ID of the LinkedIn profile (e.g., 'company/hubspot'). - **num_posts** (integer) - Optional - The number of recent posts to retrieve. Defaults to 5. ### Request Example ```python { "profile_url_or_id": "company/hubspot", "num_posts": 5 } ``` ### Response #### Success Response (200) - **status** (integer) - The status code of the response. - **results** (array) - A list of recent posts or activity objects. #### Response Example ```json { "status": 200, "results": [ { "text": "New blog post on AI trends...", "timestamp": "2024-07-26T10:00:00Z" } ] } ``` ``` -------------------------------- ### Execute Raw Actions with Python SDK Source: https://github.com/onstartups/python_sdk/blob/main/README.md Demonstrates the use of the generic `action` method for executing any available action. This provides maximum flexibility by allowing direct specification of the action ID and its parameters. ```python response = client.action( action_id="getGoogleNews", params={ "query": "AI news", "date_range": "7d", "location": "Boston" } ) print(response['results']) ``` -------------------------------- ### Convert File using Python SDK Source: https://github.com/onstartups/python_sdk/blob/main/README.md Demonstrates how to convert a file to a target format using the `convert_file` method. It specifies the file URL and the desired output format, then prints the results if the conversion is successful. ```python response = client.convert_file( file_url="https://example.com/document.pdf", target_format="txt" ) if response['status'] == 200: print(f"Converted file: {response['results']}") ``` -------------------------------- ### Get Recent Tweets API Source: https://context7.com/onstartups/python_sdk/llms.txt Fetch recent tweets from a Twitter/X user for social media monitoring and content analysis. ```APIDOC ## POST /get_recent_tweets ### Description Fetch recent tweets from a Twitter/X user for social media monitoring and content analysis. ### Method POST ### Endpoint /get_recent_tweets ### Parameters #### Query Parameters - **username** (string) - Required - The username of the Twitter/X user (without '@'). - **count** (integer) - Optional - The number of recent tweets to retrieve. Defaults to 5. ### Request Example ```python { "username": "elonmusk", "count": 5 } ``` ### Response #### Success Response (200) - **status** (integer) - The status code of the response. - **results** (array) - A list of recent tweet objects, each containing 'text' and other tweet details. #### Response Example ```json { "status": 200, "results": [ { "text": "Excited about the new SpaceX launch!", "id": "1234567890" } ] } ``` ``` -------------------------------- ### Get Twitter User API Source: https://context7.com/onstartups/python_sdk/llms.txt Retrieve Twitter/X user profile information including bio, follower count, and account details. ```APIDOC ## POST /get_twitter_user ### Description Retrieve Twitter/X user profile information including bio, follower count, and account details. ### Method POST ### Endpoint /get_twitter_user ### Parameters #### Query Parameters - **username** (string) - Required - The username of the Twitter/X user (without '@'). ### Request Example ```python { "username": "openai" } ``` ### Response #### Success Response (200) - **status** (integer) - The status code of the response. - **results** (object) - An object containing user profile data (e.g., bio, follower count). #### Response Example ```json { "status": 200, "results": { "name": "OpenAI", "username": "openai", "bio": "We are building safe Artificial General Intelligence.", "followers_count": 5000000 } } ``` ``` -------------------------------- ### Get LinkedIn Profile API Source: https://context7.com/onstartups/python_sdk/llms.txt Retrieve LinkedIn profile information for individuals or companies. Useful for lead enrichment and professional networking automation. ```APIDOC ## POST /get_linkedin_profile ### Description Retrieve LinkedIn profile information for individuals or companies. Useful for lead enrichment and professional networking automation. ### Method POST ### Endpoint /get_linkedin_profile ### Parameters #### Query Parameters - **profile_url_or_id** (string) - Required - The URL or ID of the LinkedIn profile (e.g., 'company/hubspot' or 'in/satyanadella'). ### Request Example ```python { "profile_url_or_id": "company/hubspot" } ``` ### Response #### Success Response (200) - **status** (integer) - The status code of the response. - **results** (object) - An object containing the LinkedIn profile data. #### Response Example ```json { "status": 200, "results": { "name": "HubSpot", "url": "https://www.linkedin.com/company/hubspot", "description": "HubSpot is a leading CRM platform..." } } ``` ``` -------------------------------- ### Get Twitter/X User Profile with Python SDK Source: https://github.com/onstartups/python_sdk/blob/main/llm.txt Retrieves Twitter/X user profile information using their handle. Returns user profile data. ```python response = client.get_twitter_user("elonmusk") print(response['results']) ``` -------------------------------- ### Available Actions Source: https://github.com/onstartups/python_sdk/blob/main/README.md A comprehensive list of all available actions that can be invoked via the `action()` method or their corresponding convenience methods. ```APIDOC ## Available Actions | Action ID | Description | Convenience Method | |---|---|---| | `grabWebText` | Get text from a webpage | `grab_web_text()` | | `grabWebScreenshot` | Screenshot a webpage | `grab_web_screenshot()` | | `getYoutubeTranscript` | Get YouTube video transcript | `get_youtube_transcript()` | | `getYoutubeChannel` | Get YouTube channel info | `get_youtube_channel()` | | `runYoutubeSearch` | Search YouTube | `search_youtube()` | | `getGoogleNews` | Get Google News articles | `get_google_news()` | | `getSearchResults` | Web search results | `search_web()` | | `getLinkedinProfile` | Get LinkedIn profile | `get_linkedin_profile()` | | `getLinkedinActivity` | Get LinkedIn posts | `get_linkedin_activity()` | | `getCompanyObject` | Company intelligence | `get_company_info()` | | `getTwitterUsers` | Twitter user info | `get_twitter_user()` | | `getRecentTweets` | Get recent tweets | `get_recent_tweets()` | | `getBlueskyPosts` | Get Bluesky posts | `get_bluesky_posts()` | | `searchBlueskyPosts` | Search Bluesky | `search_bluesky()` | | `getInstagramProfile` | Instagram profile | `get_instagram_profile()` | | `invokeLlm` | Chat with LLM | `chat()` | | `generateImage` | Generate images | `generate_image()` | | `outputAudio` | Text to speech | `text_to_audio()` | | `convertFile` | Convert files | `convert_file()` | | `convertFileOptions` | Get conversion options | `get_convert_options()` | | `storeVariableToDatabase` | Store variable | `store_variable()` | | `getVariableFromDatabase` | Get variable | `get_variable()` | | `invokeAgent` | Call another agent | `invoke_agent()` | | `restCall` | Make REST API call | `rest_call()` ``` -------------------------------- ### Get YouTube Transcript with Agent.ai Python SDK Source: https://github.com/onstartups/python_sdk/blob/main/llm.txt Retrieves the transcript of a YouTube video given its URL using `client.get_youtube_transcript`. The full transcript text is returned in the results. ```python response = client.get_youtube_transcript("https://www.youtube.com/watch?v=dQw4w9WgXcQ") print(response['results']) # Full transcript text ``` -------------------------------- ### Convert Text to Audio using Python Source: https://context7.com/onstartups/python_sdk/llms.txt Converts provided text into speech audio using different voice options. The function returns a URL pointing to the generated audio file. Requires AgentAiClient initialization. ```python from agentai import AgentAiClient client = AgentAiClient() response = client.text_to_audio( text="Hello, welcome to agent.ai! This is a text-to-speech demo.", voice="alloy" ) if response['status'] == 200: audio_url = response['results'] print(f"Audio URL: {audio_url}") else: print(f"Error: {response['error']}") # Output: Audio URL: https://storage.agent.ai/audio/tts_abc123.mp3 ``` -------------------------------- ### Get LinkedIn Profile Information with Python SDK Source: https://github.com/onstartups/python_sdk/blob/main/llm.txt Fetches LinkedIn profile information using a profile handle. Supports both personal and company profiles. Returns profile data. ```python # Personal profile response = client.get_linkedin_profile("in/satyanadella") # Company profile response = client.get_linkedin_profile("company/microsoft") print(response['results']) ``` -------------------------------- ### Convert Files Between Formats using Python Source: https://context7.com/onstartups/python_sdk/llms.txt Facilitates file format conversions, such as PDF to text or DOCX to PDF. Supports a wide array of document and media types. Requires AgentAiClient and takes a file URL and target format as input. ```python from agentai import AgentAiClient client = AgentAiClient() # Check available conversion options first options_response = client.get_convert_options("pdf") if options_response['status'] == 200: print(f"PDF can be converted to: {options_response['results']}") # Convert a PDF to text response = client.convert_file( file_url="https://example.com/document.pdf", target_format="txt" ) if response['status'] == 200: converted_url = response['results'] print(f"Converted file URL: {converted_url}") else: print(f"Error: {response['error']}") # Output: # PDF can be converted to: ['txt', 'docx', 'html', ...] # Converted file URL: https://storage.agent.ai/converted/doc_abc123.txt ``` -------------------------------- ### Get Recent Tweets from Twitter/X User with Python SDK Source: https://github.com/onstartups/python_sdk/blob/main/llm.txt Fetches recent tweets from a specified Twitter/X user. Allows specifying the number of tweets to retrieve. Returns a list of tweets. ```python response = client.get_recent_tweets("openai", count=5) for tweet in response['results']: print(tweet['text']) ``` -------------------------------- ### Get LinkedIn Activity/Posts with Python SDK Source: https://github.com/onstartups/python_sdk/blob/main/llm.txt Retrieves recent LinkedIn activity or posts for a given profile handle. Allows specifying the number of posts to fetch. Returns a list of posts. ```python response = client.get_linkedin_activity("in/username", num_posts=5) print(response['results']) ``` -------------------------------- ### Search Bluesky Posts by Keyword using Python Source: https://context7.com/onstartups/python_sdk/llms.txt Enables searching for Bluesky posts based on keywords or phrases, useful for social listening and trend analysis. Initializes AgentAiClient and returns search results or an error. ```python from agentai import AgentAiClient client = AgentAiClient() response = client.search_bluesky("python programming", count=10) if response['status'] == 200: print(f"Search results: {response['results']}") else: print(f"Error: {response['error']}") ``` -------------------------------- ### Make REST API Calls with Python SDK Source: https://github.com/onstartups/python_sdk/blob/main/README.md Illustrates how to make a REST API call using the `rest_call` method. This includes specifying the URL, HTTP method, headers, and request body for the API interaction. ```python response = client.rest_call( url="https://api.example.com/data", method="POST", headers={"X-Custom-Header": "value"}, body={"key": "value"} ) print(response['results']) ``` -------------------------------- ### Store and Retrieve Database Variables with Python SDK Source: https://github.com/onstartups/python_sdk/blob/main/README.md Shows how to store a variable in the database using `store_variable` and retrieve it later using `get_variable`. This is useful for persisting user preferences or other key-value data. ```python # Store a variable client.store_variable("user_preference", "dark_mode") # Retrieve a variable response = client.get_variable("user_preference") print(response['results']) ``` -------------------------------- ### Get Company Information by Domain with Python SDK Source: https://github.com/onstartups/python_sdk/blob/main/llm.txt Fetches company intelligence data based on a company domain. Returns detailed company information including name, industry, and employee count. ```python response = client.get_company_info("hubspot.com") company = response['results'] print(f"Name: {company.get('name')}") print(f"Industry: {company.get('category', {}).get('industry')}") print(f"Employees: {company.get('metrics', {}).get('employeesRange')}") ``` -------------------------------- ### Raw Actions API Source: https://github.com/onstartups/python_sdk/blob/main/README.md Execute any available action directly using the `action` method, providing the action ID and parameters. ```APIDOC ## POST /action ### Description Executes a raw action with specified parameters. This provides maximum flexibility for available actions. ### Method POST ### Endpoint /action ### Parameters #### Request Body - **action_id** (string) - Required - The unique identifier of the action to execute (e.g., 'getGoogleNews'). - **params** (object) - Optional - A dictionary of parameters required by the action. ### Request Example ```python response = client.action( action_id="getGoogleNews", params={ "query": "AI news", "date_range": "7d", "location": "Boston" } ) print(response['results']) ``` ### Response #### Success Response (200) - **status** (integer) - The HTTP status code of the action execution. - **results** (object) - The output data from the executed action. #### Response Example ```json { "status": 200, "results": [ { "title": "AI Advancements in 2024", "link": "http://news.example.com/ai-advancements" } ] } ``` ### Available Actions See the full list of actions and their parameters in the [Available Actions table](#available-actions). ``` -------------------------------- ### Get Google News with Agent.ai Python SDK Source: https://github.com/onstartups/python_sdk/blob/main/llm.txt Retrieves Google News articles matching a query using `client.get_google_news`. Supports filtering by date range and location, returning a list of articles. ```python response = client.get_google_news("artificial intelligence", date_range="7d") for article in response['results'].get('organic_results', []): print(article['title'], article['link']) ``` -------------------------------- ### Authenticate AgentAiClient with Environment Variable or Token Source: https://github.com/onstartups/python_sdk/blob/main/README.md Demonstrates two methods for authenticating the AgentAiClient: using an environment variable (AGENTAI_API_KEY) or passing the bearer token directly during client initialization. The environment variable method is recommended for security and ease of use. ```python from agentai import AgentAiClient # Option A: Environment Variable (Recommended) client = AgentAiClient() # Uses AGENTAI_API_KEY env var # Option B: Pass Token Directly # client = AgentAiClient(bearer_token="your_api_key_here") ``` -------------------------------- ### Search YouTube API Source: https://context7.com/onstartups/python_sdk/llms.txt Search YouTube for videos and retrieve metadata such as titles, links, and descriptions. ```APIDOC ## POST /search_youtube ### Description Search YouTube for videos and retrieve video metadata including titles, links, and descriptions. ### Method POST ### Endpoint /search_youtube ### Parameters #### Query Parameters - **query** (string) - Required - The search query for YouTube videos. - **max_results** (integer) - Optional - The maximum number of results to return. ### Request Example ```python { "query": "python tutorials", "max_results": 5 } ``` ### Response #### Success Response (200) - **status** (integer) - The status code of the response. - **results** (array) - A list of video objects, each containing 'title' and 'link'. #### Response Example ```json { "status": 200, "results": [ { "title": "Python Tutorial - Python Full Course for Beginners", "link": "https://www.youtube.com/watch?v=..." }, { "title": "Learn Python in 1 Hour", "link": "https://www.youtube.com/watch?v=..." } ] } ``` ``` -------------------------------- ### Capture Web Page Screenshots with Agent.ai SDK Source: https://context7.com/onstartups/python_sdk/llms.txt Illustrates how to capture screenshots of web pages using `grab_web_screenshot`. The function supports both viewport-only and full-page screenshots, returning a URL to the image. ```python from agentai import AgentAiClient client = AgentAiClient() # Take viewport screenshot response = client.grab_web_screenshot("https://example.com") if response['status'] == 200: print(f"Screenshot URL: {response['results']}") # Take full-page screenshot response = client.grab_web_screenshot("https://example.com", full_page=True) if response['status'] == 200: print(f"Full page screenshot: {response['results']}") # Output: Screenshot URL: https://storage.agent.ai/screenshots/abc123.png ``` -------------------------------- ### Search YouTube Videos with Python Source: https://context7.com/onstartups/python_sdk/llms.txt Searches YouTube for videos based on a query and returns metadata such as title, link, and description. Requires the agentai library. Handles successful responses by iterating through results and printing video details, or prints an error message if the status is not 200. ```python from agentai import AgentAiClient client = AgentAiClient() response = client.search_youtube("python tutorials", max_results=5) if response['status'] == 200: for video in response['results']: print(f"Title: {video['title']}") print(f"Link: {video['link']}") print("---") # Output: # Title: Python Tutorial - Python Full Course for Beginners # Link: https://www.youtube.com/watch?v=... # --- # Title: Learn Python in 1 Hour # Link: https://www.youtube.com/watch?v=... ``` -------------------------------- ### Search YouTube with Agent.ai Python SDK Source: https://github.com/onstartups/python_sdk/blob/main/llm.txt Performs a YouTube search based on a query using `client.search_youtube`. Allows specifying the maximum number of results and returns a list of video details. ```python response = client.search_youtube("python tutorials", max_results=5) for video in response['results']: print(video['title'], video['link']) ``` -------------------------------- ### convert_file Source: https://context7.com/onstartups/python_sdk/llms.txt Converts files between various formats, such as PDF to text or DOCX to PDF. ```APIDOC ## POST /file/convert ### Description Convert files between formats (e.g., PDF to text, DOCX to PDF). Supports a wide range of document and media formats. ### Method POST ### Endpoint `/file/convert` ### Request Body - **file_url** (string) - Required - The URL of the file to convert. - **target_format** (string) - Required - The desired output format (e.g., "txt", "pdf", "docx"). ### Response #### Success Response (200) - **status** (integer) - The status code of the response (200 for success). - **results** (string) - The URL of the converted file. #### Error Response - **status** (integer) - The status code of the error (e.g., 400, 500). - **error** (string) - A message describing the error. ### Request Example ```python from agentai import AgentAiClient client = AgentAiClient() response = client.convert_file( file_url="https://example.com/document.pdf", target_format="txt" ) ``` ### Response Example (Success) ```json { "status": 200, "results": "https://storage.agent.ai/converted/doc_abc123.txt" } ``` ## GET /file/convert/options ### Description Retrieves the available conversion options for a given input file format. ### Method GET ### Endpoint `/file/convert/options` ### Query Parameters - **input_format** (string) - Required - The format of the input file (e.g., "pdf", "docx"). ### Response #### Success Response (200) - **status** (integer) - The status code of the response (200 for success). - **results** (array) - A list of strings representing the formats the input file can be converted to. #### Error Response - **status** (integer) - The status code of the error (e.g., 400, 500). - **error** (string) - A message describing the error. ### Request Example ```python from agentai import AgentAiClient client = AgentAiClient() options_response = client.get_convert_options("pdf") ``` ### Response Example (Success) ```json { "status": 200, "results": ["txt", "docx", "html", ...] } ``` ``` -------------------------------- ### text_to_audio Source: https://context7.com/onstartups/python_sdk/llms.txt Converts provided text into speech audio using various voice options and returns a URL to the audio file. ```APIDOC ## POST /ai/text-to-audio ### Description Convert text to speech audio using various voice options. Returns a URL to the generated audio file. ### Method POST ### Endpoint `/ai/text-to-audio` ### Request Body - **text** (string) - Required - The text to convert to speech. - **voice** (string) - Optional - The voice to use for the speech synthesis. Examples: "alloy", "echo", "fable". Defaults to a standard voice. ### Response #### Success Response (200) - **status** (integer) - The status code of the response (200 for success). - **results** (string) - The URL of the generated audio file. #### Error Response - **status** (integer) - The status code of the error (e.g., 400, 500). - **error** (string) - A message describing the error. ### Request Example ```python from agentai import AgentAiClient client = AgentAiClient() response = client.text_to_audio( text="Hello, welcome to agent.ai! This is a text-to-speech demo.", voice="alloy" ) ``` ### Response Example (Success) ```json { "status": 200, "results": "https://storage.agent.ai/audio/tts_abc123.mp3" } ``` ``` -------------------------------- ### Get Instagram Profile Information using Python Source: https://context7.com/onstartups/python_sdk/llms.txt Retrieves public profile details for a given Instagram username, including bio, follower count, and post count. Uses the AgentAiClient to fetch data and returns profile information or an error. ```python from agentai import AgentAiClient client = AgentAiClient() response = client.get_instagram_profile("instagram") if response['status'] == 200: profile = response['results'] print(f"Profile: {profile}") else: print(f"Error: {response['error']}") ``` -------------------------------- ### File Conversion API Source: https://github.com/onstartups/python_sdk/blob/main/README.md Convert files from one format to another using the `convert_file` method. Specify the file URL and the target format. ```APIDOC ## POST /convert_file ### Description Converts a file from a given URL to a specified target format. ### Method POST ### Endpoint /convert_file ### Parameters #### Query Parameters - **file_url** (string) - Required - The URL of the file to convert. - **target_format** (string) - Required - The desired output format (e.g., 'txt'). ### Request Example ```python response = client.convert_file( file_url="https://example.com/document.pdf", target_format="txt" ) ``` ### Response #### Success Response (200) - **status** (integer) - The HTTP status code of the operation. - **results** (object) - The result of the conversion, typically the content or URL of the converted file. #### Response Example ```json { "status": 200, "results": "Converted file content..." } ``` ``` -------------------------------- ### Generate AI Images using Python Source: https://context7.com/onstartups/python_sdk/llms.txt Creates AI-generated images from text prompts using models like DALL-E 3 or Stable Diffusion. Supports various aspect ratios and styles. Requires AgentAiClient and returns a URL to the generated image or an error. ```python from agentai import AgentAiClient client = AgentAiClient() response = client.generate_image( prompt="A futuristic city with flying cars at sunset", model="DALL-E 3", # Options: "DALL-E 3", "Stable Diffusion" style="photorealistic", # Style description aspect_ratio="16:9" # Options: 1:1, 16:9, 9:16, 4:3, 3:4 ) if response['status'] == 200: image_url = response['results']['images'][0]['url'] print(f"Generated image URL: {image_url}") else: print(f"Error: {response['error']}") # Output: Generated image URL: https://storage.agent.ai/images/generated_abc123.png ```