Back to prompt library
OpenAI Agent Setup with Basic Tool Calling
Linked challenge: Autonomous Crypto Compliance Agent
Prompt source
implementation29 lines4 sectionsNo variables1 code block
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
```