Python SDK

Learn how to use the AI Studio Python SDK.

We offer a simple Python SDK for seamlessly interacting with Oxylabs AI Studio APIarrow-up-right services, including AI-Scraper, AI-Crawler, AI-Browser-Agent, and other data extraction tools.

Requirements

  • python 3.10 and above

  • AI Studio API key

Installation

pip install oxylabs-ai-studio

Usage

Crawl (AiCrawler.crawl)

from oxylabs_ai_studio.apps.ai_crawler import AiCrawler

crawler = AiCrawler(api_key="<API_KEY>")

url = "https://oxylabs.io"
result = crawler.crawl(
    url=url,
    user_prompt="Find all pages with proxy products pricing",
    output_format="markdown",
    render_javascript=False,
    return_sources_limit=3,
    geo_location="US",
)
print("Results:")
for item in result.data:
    print(item, "\n")

Input parameters

  • url (str): Starting URL to crawl (required)

  • user_prompt (str): Natural language prompt to guide extraction (required)

  • output_format (Literal["json", "markdown"]): Output format (default: "markdown")

  • schema (dict | None): OpenAPI schema for structured extraction (required if output_format is "json")

  • render_javascript (bool): Render JavaScript (default: False)

  • return_sources_limit (int): Max number of sources to return (default: 25)

  • geo_location (str): proxy location in ISO2 format.

Scrape (AiScraper.scrape)

Input parameters

  • url (str): Target URL to scrape (required)

  • output_format (Literal["json", "markdown"]): Output format (default: "markdown")

  • schema (dict | None): OpenAPI schema for structured extraction (required if output_format is "json")

  • render_javascript (bool): Render JavaScript (default: False)

  • geo_location (str): proxy location in ISO2 format.

Browser Agent (BrowserAgent.run)

Input parameters

  • url (str): Starting URL to browse (required)

  • user_prompt (str): Natural language prompt for extraction (required)

  • output_format (Literal["json", "markdown", "html", "screenshot"]): Output format (default: "markdown")

  • schema (dict | None): OpenAPI schema for structured extraction (required if output_format is "json")

  • geo_location (str): proxy location in ISO2 format.

Search (AiSearch.search)

Input parameters

  • query (str): What to search for (required)

  • limit (int): Maximum number of results to return (default: 10, maximum: 50)

  • render_javascript (bool): Render JavaScript (default: False)

  • return_content (bool): Whether to return markdown contents in results (default: True)

  • geo_location (str): search proxy location in ISO2 format.

Map (AiMap.map)

Input parameters

  • url (str): Starting URL to crawl (required)

  • user_prompt (str): Natural language prompt to guide extraction (required)

  • render_javascript (bool): Render JavaScript (default: False)

  • return_sources_limit (int): Max number of sources to return (default: 25)

  • geo_location (str): proxy location in ISO2 format.

Usage examples

See the examplesarrow-up-right folder in our GitHub for detailed usage examples of each method (each method has a corresponding async version).

Last updated

Was this helpful?