Use GenVR models with OpenAI function calling
OpenAI's function calling allows GPT models to call external APIs. GenVR provides pre-built function schemas for all models, making it easy to integrate generative AI into your OpenAI agents.
Browse the model library, select a model, and click "Download OpenAI" to get the function schema.
Configure your GenVR credentials:
export GENVR_TEST_UID="your_user_id"
export GENVR_API_TOKEN="your_access_token"
export OPENAI_API_KEY="your_openai_key"Import and use the function with OpenAI SDK:
from openai import OpenAI
from flux_dev_openai_function import FUNCTION_DEFINITION, execute_generate_imagegen_flux_dev
client = OpenAI(api_key="YOUR_OPENAI_API_KEY")
# Chat with function calling enabled
response = client.chat.completions.create(
model="gpt-4",
messages=[
{"role": "user", "content": "Generate an image of a sunset over mountains"}
],
tools=[FUNCTION_DEFINITION],
tool_choice="auto"
)
# Handle function calls
if response.choices[0].message.tool_calls:
for tool_call in response.choices[0].message.tool_calls:
import json
arguments = json.loads(tool_call.function.arguments)
# Execute the GenVR function
result = execute_generate_imagegen_flux_dev(arguments)
if result.get("success"):
print(f"Generated image: {result['content']}")
else:
print(f"Error: {result['error']}")Function schemas are automatically generated from each model's parameter definitions. Always up-to-date with the latest model specifications.
Each download includes both the schema definition and a complete execution function that handles the GenVR API workflow.
Proper parameter types, constraints, and descriptions ensure OpenAI generates valid function calls with correct argument types.
Built-in error handling for network issues, timeouts, and generation failures. Returns clear error messages to your agent.
Build a chatbot that can generate images, videos, or other content based on natural language requests.
Create agents that automatically generate content for social media, marketing, or product demos.
Chain multiple GenVR models together - generate an image, then animate it, then add effects.