← Back to docs
OpenAI
OpenAI's function calling lets GPT-4 and other models interact with external tools. Astapa provides pre-built functions that give your AI safe, sandboxed database access.
Features
- Pre-built OpenAI function definitions
- Compatible with GPT-4, GPT-4 Turbo, and GPT-3.5
- Automatic parameter validation
- Staged mutations with human review
- Works with Assistants API and Chat Completions
Quick Start
example.py
from openai import OpenAI
from astapa import get_openai_tools, AstapaClient
client = OpenAI()
astapa = AstapaClient(api_url="http://localhost:8080")
# Get Astapa tools for OpenAI
tools = get_openai_tools(astapa)
# Use with function calling
response = client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": "Show me all premium users"}],
tools=tools
)
# Execute the function call safely
result = astapa.execute(response.choices[0].message.tool_calls[0])