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

# Python Agent SDK से संरचित JSON निकालें

> Phaseo Gateway के ज़रिए strict JSON लौटाने वाले सीमित local-tool loop के लिए Python Agent SDK उपयोग करें।

Python workflow को इनकी ज़रूरत हो, तो यह रेसिपी उपयोग करें:

* एक स्थानीय lookup टूल
* एक सीमित agent loop
* एक सख्त JSON output shape

## 1. SDK तैयार करें

<Note type="warning">Python Agent SDK पैकेज अभी PyPI पर उपलब्ध नहीं है।[सोर्स से इंस्टॉल करने के निर्देश](../sdk-reference/python/agent-sdk-installation.mdx) देखें।</Note>

## 2. स्थानीय टूल तय करें

```python theme={null}
from phaseo_agent import AgentTool, define_tool

lookup_policy = define_tool(
    AgentTool(
        id="lookup-policy",
        description="Look up one internal policy by slug.",
        parameters={
            "type": "object",
            "properties": {
                "slug": {"type": "string"},
            },
            "required": ["slug"],
            "additionalProperties": False,
        },
        execute=lambda input, ctx: {
            "slug": input["slug"],
            "summary": "Presets centralize routing, prompts, and caching defaults.",
        },
    )
)
```

## 3. एजेंट बनाएँ

```python theme={null}
from phaseo_agent import create_agent

agent = create_agent(
    {
        "id": "policy-extractor",
        "model": "openai/gpt-5.4-nano",
        "instructions": "Use tools when needed and return concise JSON.",
        "tools": [lookup_policy],
        "parse_output": lambda text: text,
    }
)
```

## 4. Gateway client के ज़रिए एजेंट चलाएँ

```python theme={null}
from phaseo_agent import create_gateway_agent_client

result = agent.run(
    input="Look up presets and return JSON with keys summary and recommendation.",
    client=create_gateway_agent_client(),
)

print(result.output)
```

## 5. यह रेसिपी कब उपयुक्त है

* orchestration एक Python worker के पास हो
* tool स्थानीय और नियतात्मक हों
* बड़ी orchestration layer बनाने से पहले strict output चाहिए

## संबंधित विषय

* [Python Agent SDK](../sdk-reference/python/agent-sdk.mdx)
* [Python से structured JSON भेजें](./sdk-python-presets-and-json.mdx)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.