OpenAI Function Calling
Use y0 with OpenAI GPT models via function calling.
Overview
While y0’s primary protocol is MCP, you can also use the tools via OpenAI’s function calling format. A JS SDK with pre-built adapters is planned.
Using with OpenAI SDK (Coming Soon)
import OpenAI from 'openai'
import { y0Tools } from '@y0exchange/sdk-js/openai'
const openai = new OpenAI()
const response = await openai.chat.completions.create({
model: 'gpt-4',
messages: [
{ role: 'user', content: 'What is the ETH balance of 0xd8dA...?' }
],
tools: y0Tools,
})Tool Definitions
The y0 tools map directly to OpenAI function calling format:
{
"type": "function",
"function": {
"name": "get_balance",
"description": "Get native and ERC-20 token balances for a wallet address",
"parameters": {
"type": "object",
"properties": {
"address": {
"type": "string",
"description": "Wallet address (0x...)"
},
"chainId": {
"type": "number",
"description": "Chain ID (default: 1)"
}
},
"required": ["address"]
}
}
}Notes
- A JS SDK (
@y0exchange/sdk-js) with pre-built OpenAI tool definitions is planned - Currently, the MCP server is the recommended integration method
- Write tools work the same way — they build unsigned transactions for user signing
- The signing flow is identical regardless of the AI framework used