Skip to main content

Documentation Index

Fetch the complete documentation index at: https://student-213fb9fc.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

Installation

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

Ollama SDK

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

client = Client(
    host="https://api.ajstudioz.co.in",
    headers={"Authorization": "Bearer YOUR_API_KEY"}
)

Chat

Chat
response = client.chat(
    model="gemma3:27b",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "What is quantum entanglement?"}
    ]
)
print(response.message.content)

Streaming

Streaming
stream = client.chat(
    model="deepseek-v3.2",
    messages=[{"role": "user", "content": "Write a short poem about the ocean."}],
    stream=True
)

for chunk in stream:
    print(chunk["message"]["content"], end="", flush=True)

Text Generation

Generate
response = client.generate(
    model="gemma3:27b",
    prompt="Explain the difference between supervised and unsupervised learning."
)
print(response["response"])

List Models

List Models
models = client.list()
for model in models.models:
    size_gb = model.size / 1e9
    print(f"{model.model:<40} {size_gb:>8.1f} GB")

Embeddings

Embeddings
result = client.embeddings(
    model="gemma3:4b",
    prompt="AJ STUDIOZ Cloud Infra provides frontier AI inference"
)
embedding = result.embedding
print(f"Dimensions: {len(embedding)}, first 5: {embedding[:5]}")

OpenAI SDK

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

client = OpenAI(
    base_url="https://api.ajstudioz.co.in/v1",
    api_key="YOUR_API_KEY"
)

Chat Completions

Chat Completions
response = client.chat.completions.create(
    model="gemma3:27b",
    messages=[
        {"role": "system", "content": "You are a helpful coding assistant."},
        {"role": "user", "content": "How do I read a file line by line in Python?"}
    ],
    temperature=0.7,
    max_tokens=512
)
print(response.choices[0].message.content)

Streaming

Streaming
stream = client.chat.completions.create(
    model="deepseek-v3.2",
    messages=[{"role": "user", "content": "Describe the web3 ecosystem in 3 paragraphs."}],
    stream=True
)

for chunk in stream:
    delta = chunk.choices[0].delta
    if delta.content:
        print(delta.content, end="", flush=True)

Function Calling

Function Calling
import json

tools = [
    {
        "type": "function",
        "function": {
            "name": "get_weather",
            "description": "Get the current weather for a city",
            "parameters": {
                "type": "object",
                "properties": {
                    "location": {"type": "string", "description": "City name, e.g. 'London'"},
                    "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
                },
                "required": ["location"]
            }
        }
    }
]

response = client.chat.completions.create(
    model="gemma3:27b",
    messages=[{"role": "user", "content": "What's the weather like in Tokyo?"}],
    tools=tools,
    tool_choice="auto"
)

if response.choices[0].finish_reason == "tool_calls":
    tool_call = response.choices[0].message.tool_calls[0]
    print(f"Function: {tool_call.function.name}")
    print(f"Arguments: {tool_call.function.arguments}")

Embeddings

Embeddings
response = client.embeddings.create(
    model="gemma3:4b",
    input="The future of AI is bright and transformative"
)
embedding = response.data[0].embedding
print(f"Embedding dim: {len(embedding)}")

Environment Variables

Store your API key in a .env file:
.env
AJSTUDIOZ_API_KEY=your_api_key_here
Load it using python-dotenv:
Load from .env
from dotenv import load_dotenv
import os
from openai import OpenAI

load_dotenv()

client = OpenAI(
    base_url="https://api.ajstudioz.co.in/v1",
    api_key=os.environ["AJSTUDIOZ_API_KEY"]
)

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
from firecrawl.v2.types import PaginationConfig
OptionTypeDefaultDescription
auto_paginateboolTrueWhen True, automatically fetches all pages and aggregates results. Set to False to fetch one page at a time.
max_pagesintNoneStop after fetching this many pages (only applies when auto_paginate=True).
max_resultsintNoneStop after collecting this many documents (only applies when auto_paginate=True).
max_wait_timeintNoneStop after this many seconds (only applies when auto_paginate=True).

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
crawl_job = client.start_crawl("https://example.com", limit=100)

# Fetch first page
status = client.get_crawl_status(
    crawl_job.id,
    pagination_config=PaginationConfig(auto_paginate=False)
)
print("First page:", len(status.data), "docs")

# Fetch subsequent pages using get_crawl_status_page
while status.next:
    status = client.get_crawl_status_page(status.next)
    print("Next page:", len(status.data), "docs")
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
status = client.get_crawl_status(
    crawl_job.id,
    pagination_config=PaginationConfig(max_pages=2, max_results=50, max_wait_time=15),
)
print("crawl limited:", status.status, "docs:", len(status.data), "next:", status.next)

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
batch_job = client.start_batch_scrape(urls)

# Fetch first page
status = client.get_batch_scrape_status(
    batch_job.id,
    pagination_config=PaginationConfig(auto_paginate=False)
)
print("First page:", len(status.data), "docs")

# Fetch subsequent pages using get_batch_scrape_status_page
while status.next:
    status = client.get_batch_scrape_status_page(status.next)
    print("Next page:", len(status.data), "docs")
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
status = client.get_batch_scrape_status(
    batch_job.id,
    pagination_config=PaginationConfig(max_pages=2, max_results=100, max_wait_time=20),
)
print("batch limited:", status.status, "docs:", len(status.data), "next:", status.next)

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
from firecrawl import Firecrawl

app = Firecrawl(api_key="fc-YOUR-API-KEY")

session = app.browser()
print(session.id)             # session ID
print(session.cdp_url)        # wss://cdp-proxy.firecrawl.dev/cdp/...
print(session.live_view_url)  # https://liveview.firecrawl.dev/...

Execute Code

Python
result = app.browser_execute(
    session.id,
    code='await page.goto("https://news.ycombinator.com")\ntitle = await page.title()\nprint(title)',
    language="python",
)
print(result.result)  # "Hacker News"
Execute JavaScript instead of Python:
Python
result = app.browser_execute(
    session.id,
    code='await page.goto("https://example.com"); const t = await page.title(); console.log(t);',
    language="node",
)

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
from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.connect_over_cdp(session.cdp_url)
    context = browser.contexts[0]
    page = context.pages[0] if context.pages else context.new_page()

    page.goto("https://example.com")
    print(page.title())

    browser.close()

List & Close Sessions

Python
# List active sessions
sessions = app.list_browsers(status="active")
for s in sessions.sessions:
    print(s.id, s.status, s.created_at)

# Close a session
app.delete_browser(session.id)