OpenAI API
The OpenAI API provides a simple interface to state-of-the-art AI models for text generation, natural language processing, computer vision, and more.
OpenAI Server
Section titled “OpenAI Server”OpenAIServer allows you to expose your agents and LLMs to external systems that support the Chat completion or Responses API.
Key benefits
- Fast setup with minimal configuration
- Support for Chat Completion API and Responses API
- Register multiple agents and LLMs on a single server
- Custom server settings
from beeai_framework.adapters.openai.serve.server import OpenAIAPIType, OpenAIServer, OpenAIServerConfigfrom beeai_framework.agents.requirement import RequirementAgentfrom beeai_framework.backend import ChatModelfrom beeai_framework.memory import UnconstrainedMemoryfrom beeai_framework.tools.weather import OpenMeteoTool
def main() -> None: llm = ChatModel.from_name("ollama:granite4:micro") agent = RequirementAgent( llm=llm, tools=[OpenMeteoTool()], memory=UnconstrainedMemory(), )
server = OpenAIServer( config=OpenAIServerConfig( port=9998, api=OpenAIAPIType.RESPONSES, ) ) server.register(agent, name="agent") server.register(llm) server.serve()
if __name__ == "__main__": main()import "dotenv/config.js";
import { OpenMeteoTool } from "beeai-framework/tools/weather/openMeteo";import { OllamaChatModel } from "beeai-framework/adapters/ollama/backend/chat";import { ToolCallingAgent } from "beeai-framework/agents/toolCalling/agent";import { UnconstrainedMemory } from "beeai-framework/memory/unconstrainedMemory";import { OpenAIServer } from "beeai-framework/adapters/openai/serve/server";
// ensure the model is pulled before runningconst llm = new OllamaChatModel("granite4:micro");
const agent = new ToolCallingAgent({ llm, memory: new UnconstrainedMemory(), tools: [ new OpenMeteoTool(), // weather tool ],});
await new OpenAIServer({ api: "responses", port: 9999 }).register(agent).serve();Agent execution (Python)
Pass execution=AgentExecutionConfig(...) to server.register() to configure
max_iterations, total_max_retries, and max_retries_per_step for the built-in
RequirementAgent, ToolCallingAgent, and ReActAgent. These options apply to every
request served by that registration. Omitted fields and fields set to None retain the
agent’s own defaults. The configuration is copied during registration, and non-empty
execution configuration is rejected for other runnable types.
You can easily call the exposed entities via cURL.
curl --location 'http://127.0.0.1:9998/responses' \--header 'Content-Type: application/json' \--data '{ "model": "agent", "conversation": "123", "stream": false, "input": "Hello, how are you?"}'curl --location 'http://127.0.0.1:9998/chat/completions' \--header 'Content-Type: application/json' \--data '{ "model": "agent", "stream": false, "messages": [ { "role": "user", "content": "Hello, how are you?" } ]}'