OpenAI Agent Setup with Basic Tool Calling

implementationChallenge

Prompt Content

Initialize your OpenAI Agent using the Assistants API. Define a `TransactionMonitor` agent with a tool called `fetch_transactions` that simulates fetching recent crypto transactions from an `Enterprise Transaction API`. Implement a basic `check_compliance` function that the agent can call. Your agent should be able to process a simple query like 'Are there any suspicious transactions?'

```python
from openai import OpenAI

client = OpenAI()

# Assume client.beta.assistants is available for Assistants API
assistant = client.beta.assistants.create(
    name="TransactionMonitor",
    instructions="You are an expert financial compliance officer. You use provided tools to monitor transactions for suspicious activity.",
    model="gpt-4o",
    tools=[
        {
            "type": "function",
            "function": {
                "name": "fetch_transactions",
                "description": "Fetches recent crypto transactions from the Enterprise Transaction API.",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "start_time": {"type": "string"}
                    },
                    "required": ["start_time"]
                },
            },
        },
        # More tools will go here
    ],
)
# ... rest of the assistant interaction code
```

Try this prompt

Open the workspace to execute this prompt with free credits, or use your own API keys for unlimited usage.

Usage Tips

Copy the prompt and paste it into your preferred AI tool (Claude, ChatGPT, Gemini)

Customize placeholder values with your specific requirements and context

For best results, provide clear examples and test different variations