> ## Documentation Index
> Fetch the complete documentation index at: https://jigsaw-13.mintlify.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Introduction

> Get started with the JigsawStack Python SDK to build powerful AI applications

<Card title="Models" href="/docs/api-reference/authentication">
  Explore our complete list of models and API references here.
</Card>

## Prerequisites

Before you begin, you'll need:

* A [JigsawStack account](https://jigsawstack.com/dashboard)
* Your [API key](https://jigsawstack.com/dashboard) from the JigsawStack dashboard
* Python 3.7 or higher installed on your system

<Info>
  The SDK is compatible with Python 3.7+ and works on all major operating systems (Windows, macOS, and Linux).
</Info>

## Installation

Install the JigsawStack Python SDK using pip:

<CodeGroup>
  ```bash pip theme={null}
  pip install jigsawstack
  ```

  ```bash pipenv theme={null}
  pipenv install jigsawstack
  ```

  ```bash poetry theme={null}
  poetry add jigsawstack
  ```
</CodeGroup>

## Authentication

There are two ways to authenticate with the JigsawStack API:

### Option 1: Environment Variable (Recommended)

Set your API key as an environment variable:

```bash theme={null}
# Linux/macOS
export JIGSAWSTACK_API_KEY='your-api-key'

# Windows (Command Prompt)
set JIGSAWSTACK_API_KEY=your-api-key

# Windows (PowerShell)
$env:JIGSAWSTACK_API_KEY = 'your-api-key'
```

Or in your project's `.env` file:

```bash .env theme={null}
JIGSAWSTACK_API_KEY='your-api-key'
```

Then initialize the SDK without explicitly providing the API key:

```python theme={null}
from jigsawstack import JigsawStack

jigsawstack = JigsawStack()  # API key will be read from environment
```

### Option 2: Direct Initialization

Provide your API key directly when initializing the SDK:

```python theme={null}
from jigsawstack import JigsawStack

jigsawstack = JigsawStack(api_key="your-api-key")
```

## Basic Usage

Here's a quick example of using the AI web scraper to extract information from an Amazon product page:

```python theme={null}
from jigsawstack import JigsawStack

# Initialize the SDK
jigsawstack = JigsawStack()  # API key from environment variables

# Define parameters for web scraping
params = {
    "url": "https://www.amazon.com/Cadbury-Mini-Caramel-Eggs-Bulk/dp/B0CWM99G5W",
    "element_prompts": ["prices", "title", "ratings", "product_details"]
}

# Make the API call
result = jigsawstack.web.ai_scrape(params)

# Print the results
print(f"Product Title: {result.get('title')}")
print(f"Price Information: {result.get('prices')}")
```

## Response Handling

JigsawStack returns structured data as Python dictionaries. Here's how to handle the response:

```python theme={null}
# Example response handling
try:
    result = jigsawstack.web.ai_scrape(params)
    
    # Access nested data
    if "prices" in result:
        current_price = result["prices"].get("current_price")
        print(f"Current Price: ${current_price}")
    
    # Iterate through multiple results
    if "product_details" in result:
        print("Product Details:")
        for key, value in result["product_details"].items():
            print(f"- {key}: {value}")
            
except Exception as e:
    print(f"Error: {e}")
```

## More Examples

### Sentiment Analysis

```python theme={null}
sentiment_result = jigsawstack.ai.sentiment({
    "text": "I absolutely love this product! It's amazing!"
})
print(f"Sentiment: {sentiment_result.get('sentiment')}")
print(f"Score: {sentiment_result.get('score')}")
```

### Text Translation

```python theme={null}
translation = jigsawstack.ai.translate({
    "text": "Hello, world!",
    "target_language": "es"  # Spanish
})
print(f"Translated text: {translation.get('translated_text')}")
```

## Next Steps

Now that you've set up the JigsawStack Python SDK, you can:

* Explore the [complete API reference](/docs/api-reference/authentication) to discover all available models
* Try out different AI capabilities like [image generation](https://jigsawstack.com/docs/api-reference/ai/image-generation), [OCR](https://jigsawstack.com/docs/api-reference/ai/vocr), and more
* Join our [Discord](https://jigsawstack.com/discord) for help and to share your projects

Start building powerful AI applications with JigsawStack today!
