Skip to main content

Installation

Install the SDK you prefer — both work with AJ STUDIOZ Cloud Infra:

Ollama SDK

Point the Ollama client to https://api.ajstudioz.co.in and pass your API key as a header:
Setup

Chat

Chat

Streaming

Streaming

Text Generation

Generate

List Models

List Models

Embeddings

Embeddings

OpenAI SDK

Point the OpenAI client to https://api.ajstudioz.co.in/v1:
Setup

Chat Completions

Chat Completions

Streaming

Streaming

Function Calling

Function Calling

Embeddings

Embeddings

Environment Variables

Store your API key in a .env file:
.env
Load it using python-dotenv:
Load from .env

Next Steps

Available Models

Browse all 32 models with sizes and capabilities

Streaming Guide

In-depth streaming patterns for Python

Function Calling

Build tool-using agents with Python

Embeddings Guide

RAG pipelines and semantic search

Usage

  1. Get an API key from firecrawl.dev
  2. Set the API key as an environment variable named FIRECRAWL_API_KEY or pass it as a parameter to the Firecrawl class.
Here’s an example of how to use the SDK:

Scraping a URL

To scrape a single URL, use the scrape method. It takes the URL as a parameter and returns the scraped document.

Crawl a Website

To crawl a website, use the crawl method. It takes the starting URL and optional options as arguments. The options allow you to specify additional settings for the crawl job, such as the maximum number of pages to crawl, allowed domains, and the output format. See Pagination for auto/manual pagination and limiting.

Sitemap-Only Crawl

Use sitemap="only" to crawl sitemap URLs only (the start URL is always included, and HTML link discovery is skipped).

Start a Crawl

Prefer non-blocking? Check out the Async Class section below.
Start a job without waiting using start_crawl. It returns a job ID you can use to check status. Use crawl when you want a waiter that blocks until completion. See Pagination for paging behavior and limits.

Checking Crawl Status

To check the status of a crawl job, use the get_crawl_status method. It takes the job ID as a parameter and returns the current status of the crawl job.

Cancelling a Crawl

To cancel an crawl job, use the cancel_crawl method. It takes the job ID of the start_crawl as a parameter and returns the cancellation status.

Map a Website

Use map to generate a list of URLs from a website. The options let you customize the mapping process, including excluding subdomains or utilizing the sitemap.

Crawling a Website with WebSockets

To crawl a website with WebSockets, start the job with start_crawl and subscribe using the watcher helper. Create a watcher with the job ID and attach handlers (e.g., for page, completed, failed) before calling start().

Pagination

Firecrawl endpoints for crawl and batch scrape return a next URL when more data is available. The Python SDK auto-paginates by default and aggregates all documents; in that case next will be None. You can disable auto-pagination or set limits to control pagination behavior.

PaginationConfig

Use PaginationConfig to control pagination behavior when calling get_crawl_status or get_batch_scrape_status:
Python

Manual Pagination Helpers

When auto_paginate=False, the response includes a next URL if more data is available. Use these helper methods to fetch subsequent pages:
  • get_crawl_status_page(next_url) - Fetch the next page of crawl results using the opaque next URL from a previous response.
  • get_batch_scrape_status_page(next_url) - Fetch the next page of batch scrape results using the opaque next URL from a previous response.
These methods return the same response type as the original status call, including a new next URL if more pages remain.

Crawl

Use the waiter method crawl for the simplest experience, or start a job and page manually.
Simple crawl (auto-pagination, default)
Manual crawl with pagination control
Start a job, then fetch one page at a time with auto_paginate=False. Use get_crawl_status_page to fetch subsequent pages:
Python
Manual crawl with limits (auto-pagination + early stop)
Keep auto-pagination on but stop early with max_pages, max_results, or max_wait_time:
Python

Batch Scrape

Use the waiter method batch_scrape, or start a job and page manually.
Simple batch scrape (auto-pagination, default)
Manual batch scrape with pagination control
Start a job, then fetch one page at a time with auto_paginate=False. Use get_batch_scrape_status_page to fetch subsequent pages:
Python
Manual batch scrape with limits (auto-pagination + early stop)
Keep auto-pagination on but stop early with max_pages, max_results, or max_wait_time:
Python

Error Handling

The SDK handles errors returned by the Firecrawl API and raises appropriate exceptions. If an error occurs during a request, an exception will be raised with a descriptive error message.

Async Class

For async operations, use the AsyncFirecrawl class. Its methods mirror Firecrawl, but they don’t block the main thread.

Browser

Launch cloud browser sessions and execute code remotely.

Create a Session

Python

Execute Code

Python
Execute JavaScript instead of Python:
Python

Profiles

Save and reuse browser state (cookies, localStorage, etc.) across sessions:

Connect via CDP

For full Playwright control, connect directly using the CDP URL:
Python

List & Close Sessions

Python