# Quickstart

**Prerequisites**

1. **Python 3.8+** (recommended: `pyenv` or `conda` for virtual environments).
2. **AgentGPT API Key** ([Get Trial Key](https://api.agent-gpt.org)).
3. **pip** (agentgpt SDK requires `pip ≥22.3`).

***

#### **1. Install the SDK**

```bash
# Install/upgrade the AgentGPT CLI & SDK  
pip install agentgpt --upgrade  
```

Verify installation:

```bash
agentgpt --version  
# Output: agentgpt, version 2.4.1 (Enterprise Edition)  
```

***

#### **2. Initialize the SDK**

Authenticate using your API key:

```python
from agentgpt import AgentGPT

# Initialize client  
client = AgentGPT(  
    api_key="YOUR_API_KEY",  
    compliance_mode="enterprise"  # Optional: Enable HIPAA/NIST RMF  
)  
```

***

#### **3. Create Your First Agent**

Define a customer service agent with **autonomous decision-making**:

```python
# Define agent configuration  
support_agent = client.agent.create(  
    name="CustomerSupportAgent",  
    role="resolve user inquiries and escalate complex cases",  
    permissions=["ticket_read", "case_escalate"],  
    tools=["sql_query", "slack_notify"],  # Pre-built tool integrations  
    compliance_tags=["GDPR", "PCI-DSS"]  
)  

print(f"Agent ID: {support_agent.id}")  
```

***

#### **4. Deploy an Agent Workflow**

Orchestrate agents using a **multi-step workflow**:

```python
from agentgpt.workflows import SequentialWorkflow  

# Define tasks  
workflow = SequentialWorkflow(name="SupportTicketResolution")  

# Task 1: Classify ticket urgency  
workflow.add_task(  
    agent_id=support_agent.id,  
    instruction="Analyze ticket text and assign priority (1-5)",  
    input_source="tickets_db"  
)  

# Task 2: Escalate high-priority cases  
workflow.add_task(  
    agent_id=support_agent.id,  
    instruction="Notify SLACK_CHANNEL_CRITICAL if priority ≥4",  
    dependencies=["task1"]  
)  

# Deploy workflow  
client.workflow.deploy(workflow)  
```

***

#### **5. Execute the Workflow**

Trigger your workflow via API or CLI:

```bash
# CLI execution  
agentgpt workflow trigger --id WORKFLOW_ID --params '{"ticket_id": 2913}'  
```

**Sample Output**:

```json
{  
  "status": "success",  
  "result": {  
    "priority": 4,  
    "slack_alert_sent": "SLACK_MSG_ID_3XK7"  
  }  
}  
```

***

#### **6. Monitor Agents**

Access real-time metrics:

```python
# Get agent performance stats  
metrics = client.agent.metrics(support_agent.id)  
print(f"Latency: {metrics.latency_ms}ms | Accuracy: {metrics.accuracy}%")  
```

***

#### **Tips & Best Practices**

1. **Debugging**: Use `agentgpt logs --tail --agent_id AGENT_ID` for real-time debugging.
2. **Testing**: Enable `dry_run=True` when prototyping workflows.
3. **Security**: Rotate API keys monthly via `client.keys.rotate()`.

***

#### **Troubleshooting**

| **Issue**             | **Solution**                                 |
| --------------------- | -------------------------------------------- |
| `AuthenticationError` | Verify API key scope (read/write/admin)      |
| `DependencyConflict`  | Use `pip install agentgpt --force-reinstall` |
| `TimeoutError`        | Increase `timeout=30` in client config       |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://agent-gpt.gitbook.io/agent-gpt/getting-started/quickstart.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
