OpenAI Agents SDK ଇଣ୍ଟେଗ୍ରେସନ୍।
Agents SDK ପ୍ୟାକେଜ୍ ନାହିଁ, ଏବଂ ଆପଣଙ୍କୁ ତାହା ଆବଶ୍ୟକ ମଧ୍ୟ ନାହିଁ। @function_tool ସହିତ ଏକ function କୁ decorate କରନ୍ତୁ, ଆସଲ blockchain0x client କୁ call କରନ୍ତୁ, ଏବଂ ଆପଣଙ୍କ agent Base ଉପରେ USDC move କରିପାରିବ।
OpenAI Agents SDK-ନିର୍ଦ୍ଦିଷ୍ଟ କୌଣସି package ନାହିଁ, ଏବଂ ଆପଣଙ୍କୁ ଦରକାର ମଧ୍ୟ ନାହିଁ। SDK ସହିତ decorated function କୁ tool ରେ ପରିଣତ କରେ, ସେଥିପାଇଁ ଆପଣ ସତ୍ୟ Python client କୁ function ଭିତରେ wrap କରି ଆପଣଙ୍କ ରେ add କରନ୍ତୁ। agent USDC ପଠାଇପାରେ, invoice settle କରିପାରେ, ଏବଂ wallet ପଢ଼ିପାରେ - single agents, handoffs, ଏବଂ underlying Responses API ଜୁଡ଼ି ମଧ୍ୟରେ। Payments Base ରେ settle ହୁଏ।
OpenAI ଯେତେବେଳେ ship କରେ, ସବୁଠାରୁ ସ୍ୱଚ୍ଛ tool-calling surface।
OpenAI Agents SDK (2025 ରେ released) ହେଉଛି Responses API ଉପରେ agents ତିଆରି କରିବା ପାଇଁ OpenAI ର recommended way। ଏହା tool registration, message loops, ଏବଂ agents ମଧ୍ୟରେ handoff ସମ୍ବନ୍ଧୀୟ boilerplate କୁ abstract କରେ, ଏବଂ clean, typed Python code ଦେଇଥାଏ। ଯଦି ଆପଣ ଆଜି ଏକ OpenAI-centric agent project ଆରମ୍ଭ କରୁଛନ୍ତି ଏବଂ framework preference ନାହିଁ, ତେବେ ଏହା ହେଉଛି ଆମେ recommend କରୁଥିବା SDK।
recipeଟି ଉଦ୍ଦେଶ୍ୟପୂର୍ଣ୍ଣଭାବେ ସରଳ। send_usdc ହେଉଛି @function_tool ସହିତ decorated ଗୋଟିଏ plain function; ଆପଣ ଏହାକୁ Agent ର tools list ରେ ଯୋଡ଼ନ୍ତି ଏବଂ Runner ଏହାକୁ ଧରିନେଇଥାଏ। କୌଣସି special configuration ନାହିଁ, ଅତିରିକ୍ତ wrapper ନାହିଁ, SDK ର କୌଣସି fork ନାହିଁ। Agents SDK ଯେତେବେଳେ ନୂତନ feature (multi-modal inputs, voice agents) ଆଣେ, ଆପଣଙ୍କ function କାମ କରିଚାଲେ କାରଣ ଏହା standard tool-calling surface ଉପରେ ଚାଲେ - ତା’ଭିତରେ କୌଣସି version-specific ଜିନିଷ ନାହିଁ।
Agents SDK ଏବଂ core SDK ଇନଷ୍ଟଲ୍ କରନ୍ତୁ। ଦୁଇଟି key।
ଯୋଡିବା ପାଇଁ blockchain0x Agents SDK package ନାହିଁ। ଆପଣ OpenAI Agents SDK (openai-agents package, Python 3.10+) ଏବଂ ଆସଲ blockchain0x core SDK install କରନ୍ତୁ, ତାପରେ ତଳେ ଥିବା function ଲେଖନ୍ତୁ। ସମ୍ପୂର୍ଣ୍ଣ dependency list ଏତିକି ହିଁ।
pip install openai-agents blockchain0xexport OPENAI_API_KEY=sk-... export BLOCKCHAIN0X_API_KEY=sk_test_... # sk_test_ = Base Sepolia, sk_live_ = Base mainnet
OPENAI_API_KEY ହେଉଛି ଆପଣଙ୍କ existing OpenAI key (Agents SDK ଏହାକୁ underlying Responses API ପାଇଁ ବ୍ୟବହାର କରେ)। BLOCKCHAIN0X_API_KEY ହେଉଛି ଆପଣଙ୍କ dashboard ରୁ sk_test_ testnet କିମ୍ବା sk_live_ mainnet key; client ଏହାକୁ environment ରୁ ପଢ଼େ। ଯଦି ଆପଣଙ୍କ agent ଟଙ୍କା ମଧ୍ୟ ଗ୍ରହଣ କରେ, webhook handler କୁ ଅତିରିକ୍ତ ଭାବେ BLOCKCHAIN0X_WEBHOOK_SECRET ଦରକାର।
ପେ କରୁଥିବା ଏକ @function_tool, ଯାହା Agent କୁ ଦିଆଯାଏ।
ନିମ୍ନରେ ସମ୍ପୂର୍ଣ୍ଣ integration ଅଛି। send_usdc real blockchain0x client କୁ call କରେ; @function_tool ଏହାକୁ tool ରେ ପରିଣତ କରେ, ଏବଂ Runner call କୁ orchestrate କରେ। SDK schema build କରିବା ପାଇଁ type hints ଏବଂ docstring ପଢେ, ସେଥିପାଇଁ ସେଗୁଡିକୁ ସତ୍ୟ ରଖନ୍ତୁ। ଏହାକୁ run କରନ୍ତୁ ଏବଂ agent Base ରେ USDC move କରେ।
from agents import Agent, Runner, function_tool from blockchain0x import Client blockchain0x = Client() # reads BLOCKCHAIN0X_API_KEY from the environment @function_tool def send_usdc(agent_id: str, to: str, amount_wei: str) -> str: """Send a USDC payment from an agent wallet. amount_wei is USDC base units (6 decimals), so "10000" is 0.01 USDC. """ return str( blockchain0x.payments.create(body={"agentId": agent_id, "to": to, "amountWei": amount_wei}) ) agent = Agent( name="treasurer", instructions="You pay vendor invoices in USDC within owner-set limits.", tools=[send_usdc], model="gpt-4o", ) result = await Runner.run( agent, input="Pay 0.01 USDC from agent agt_123 to 0xVendor for the dataset.", ) print(result.final_output)
When the agent decides to pay, it calls send_usdc, the SDK submits the transfer, and you get a transaction hash back. amount_wei is base units, so 0.01 USDC is "10000". A sk_test_ key keeps it on Base Sepolia until you switch to sk_live_. Add more functions - read a wallet, settle an invoice - the same way; each is another @function_tool in the list.
ସାଇନ୍ କରାଯାଇଥିବା ଓବ୍ହେକ୍ ସହିତ ଆସନ୍ତା ଦେୟଗୁଡିକୁ ନିଶ୍ଚୟ କରନ୍ତୁ।
ଯଦି ଆପଣଙ୍କ agent ମଧ୍ୟ USDC receive କରେ, polling ଚାଇଁତି ନୁହେଁ, webhook ଦ୍ୱାରା ଏହାକୁ confirm କରନ୍ତୁ। verify helper Node SDK ସହିତ ଆସେ; Python service ରେ ଆପଣ documented HMAC ଅନୁସାରେ ହାତେ verify କରନ୍ତି, ଯାହା helper ହିଁ କରେ। ତଳେ FastAPI example ଅଛି; ସେଇ code ଯେକୌଣସି async Python framework ରେ କାମ କରେ।
import hmac, hashlib, os, time from fastapi import FastAPI, Request, HTTPException app = FastAPI() SECRET = os.environ["BLOCKCHAIN0X_WEBHOOK_SECRET"].encode() @app.post("/webhooks/payment") async def receive(request: Request): raw = await request.body() # RAW bytes - do not parse first sig = request.headers.get("X-Blockchain0x-Signature", "") ts = request.headers.get("X-Blockchain0x-Timestamp", "") parts = dict(p.split("=", 1) for p in sig.split(",") if "=" in p) t, v1 = parts.get("t", ts), parts.get("v1", sig) want = hmac.new(SECRET, t.encode() + b"." + raw, hashlib.sha256).hexdigest() if not hmac.compare_digest(want, v1) or abs(time.time() - int(t)) > 300: raise HTTPException(status_code=401) if request.headers.get("X-Blockchain0x-Event-Type") == "payment.received": await trigger_followup() # USDC landed - run the next step return {"ok": True}
algorithm ଟି t.rawBody string ଉପରେ HMAC-SHA256, constant-time compare, ଏବଂ 300-second replay window ବ୍ୟବହାର କରେ। await request.body() ମାଧ୍ୟମରେ raw body ପଢ଼ନ୍ତୁ, କେବେ ମଧ୍ୟ request.json() re-serialized କରନ୍ତୁ ନାହିଁ, କାରଣ ଏହା signature ଆବର୍ତ୍ତିତ bytes କୁ ପରିବର୍ତ୍ତନ କରେ। shipped events ହେଉଛି payment.received, payment.sent, wallet.deployed, ଏବଂ webhook.test। heavy follow-up work ପାଇଁ, job (Celery, arq) enqueue କରନ୍ତୁ ଏବଂ handler କୁ block କରିବା ପେକ୍ଷା ସତ୍ୱର 200 respond କରନ୍ତୁ।
ଆପଣ wrap କରୁଥିବା client open ଅଟେ। ଏହାକୁ ପଢ଼ନ୍ତୁ।
Clone କରିବା ପାଇଁ Agents SDK starter package ନାହିଁ - ଉପରେ ଥିବା recipe ହିଁ integration। blockchain0x SDKs GitHub ଉପରେ open source ଅଟେ; ଏହି recipe Python SDK (blockchain0x-python) କୁ wrap କରେ, ଏବଂ docs ରେ full method surface ଅଛି। function bodies ପାଇଁ reference ଭାବେ ଏହାକୁ ପଢନ୍ତୁ।
github.com/tosh-labs/blockchain0x-pythonFull SDK method surface ଏବଂ scopes the docs ରେ documented ଅଛି। Base Sepolia ବିରୁଦ୍ଧରେ sk_test_ key ରୁ ଆରମ୍ଭ କରନ୍ତୁ, ପରେ function ଆପଣ ଆଶା କରୁଥିବାଭଳି କାମ କଲେ sk_live_ କୁ switch କରନ୍ତୁ।
ପ୍ରଥମ ସଂଯୋଜନରେ ଦେଖିବାକୁ ଯୋଗ୍ୟ ପାଞ୍ଚ ଜିନିଷ।
ଏହାଗୁଡିକ ଆମର ସମର୍ଥନ ଇନବକ୍ସରୁ ଆସିଛି। ଏହାଗୁଡିକୁ ପୂର୍ବରୁ ଜାଣିବା ଏକ ଘଣ୍ଟା ସଂରକ୍ଷଣ କରେ।
କୌଣସି Agents SDK package ନାହିଁ - ଆପଣ SDK କୁ wrap କରନ୍ତୁ
Blockchain0x LangChain ଏବଂ CrewAI ପାଇଁ adapters ସହିତ MCP server ମଧ୍ୟ ship କରେ; OpenAI Agents SDK ପାଇଁ dedicated package ନାହିଁ। ଉପରେ ଥିବା recipe ହିଁ path: ଏକ ସାଧାରଣ typed function କୁ @function_tool ସହିତ decorate କରନ୍ତୁ, ଭିତରେ real blockchain0x client କୁ call କରନ୍ତୁ, ଏବଂ ଏହାକୁ Agent(tools=[...]) ରେ add କରନ୍ତୁ। SDK tool schema build କରିବା ପାଇଁ signature ଏବଂ docstring ପଢେ, ସେଥିପାଇଁ docstring କୁ ସଠିକ୍ ରଖନ୍ତୁ।
Agents SDK ହେଉଛି Assistants API ନୁହେଁ
OpenAI Agents SDK (openai-agents package, ଯାହାକୁ agents ଭାବେ import କରାଯାଏ) ପୁରୁଣା Assistants API ଠାରୁ ଭିନ୍ନ product। ଏହି recipe Agents SDK କୁ target କରେ: Responses API ଉପରେ Agent + Runner + @function_tool। ଯଦି ଆପଣ client.beta.assistants.create(...) କୁ call କରୁଛନ୍ତି, ତେବେ ଆପଣ OpenAI ଦ୍ୱାରା ବନ୍ଦ କରାଯାଉଥିବା ପୁରୁଣା threads/runs model ଉପରେ ଅଛନ୍ତି - Agents SDK କୁ move କରନ୍ତୁ ଏବଂ ଉପରୋକ୍ତ function ସିଧାସଳଖ fit ହୋଇଯିବ।
ରାଶିଗୁଡ଼ିକ USDC base units ରେ, string ଭାବେ
payments.create takes amountWei: a string of USDC base units, not a float. USDC has 6 decimals, so 0.01 USDC is "10000" and 5 USDC is "5000000". Type the function argument as str; a float will lose precision before it reaches the API. Keep it a string end to end.
send_payment ପ୍ରାରମ୍ଭରେ 503 ଫେରାଇପାରେ
payments.create default ଭାବରେ retry କରେ ନାହିଁ ଏବଂ chain adapter ଆପଣଙ୍କ network ପାଇଁ wired ହେଉପର୍ଯ୍ୟନ୍ତ 503 ଫେରାଇପାରେ। error କୁ ଆପଣଙ୍କ function ଭିତରେ ଧରନ୍ତୁ ଏବଂ model କାର୍ଯ୍ୟ କରିପାରିବା ପାଇଁ ଏକ ସ୍ପଷ୍ଟ message ଫେରାନ୍ତୁ, Runner loop କରିବାକୁ ଦିଅନ୍ତୁ ନାହିଁ। auto-minted idempotency key ଅର୍ଥ manual retry ଦୁଇଥର ଭୁଗତାନ କରିବ ନାହିଁ।
Async-ମାତ୍ର ରନ୍ଟାଇମ୍
Agents SDK async-first - await Runner.run(...)। ଆପଣଙ୍କ tool ଭିତରେ blockchain0x call synchronous, ଯାହା ଗୋଟିଏ ଶୀଘ୍ର payment ପାଇଁ ଠିକ୍, କିନ୍ତୁ load ରେ loop କୁ block କରେ। ଯଦି ଆପଣ ଅନେକ concurrent agent ଚଳାଉଛନ୍ତି, ତେବେ SDK call କୁ asyncio.to_thread ସହ wrap କରନ୍ତୁ। Sync entry point ରୁ, top level ରେ asyncio.run() ବ୍ୟବହାର କରନ୍ତୁ।