AG-Kit Server provides OpenAI-compatible endpoints at /chat/completions (or /v1/aibot/bots/{AgentId}/chat/completions in cloud environments):
from ag_kit_py.server import AgentServiceAppfrom ag_kit_py.agents import LangGraphAgentfrom langgraph.graph import StateGraph, MessagesStatedef create_agent(): # Use the actual chat workflow from examples from python_sdk.examples.langgraph import build_chat_workflow workflow = build_chat_workflow() agent = LangGraphAgent( name='openai-compatible-agent', description='You are a helpful assistant.', graph=workflow ) return {'agent': agent}AgentServiceApp().run(create_agent, port=3000)# OpenAI API available at http://localhost:3000/chat/completions
AG-Kit can also consume OpenAI-compatible APIs from other services:
from ag_kit_py.agents import LangGraphAgentfrom langgraph.graph import StateGraph, MessagesState# Use the actual chat workflow from examplesfrom python_sdk.examples.langgraph import build_chat_workflowworkflow = build_chat_workflow()# Note: External API integration would be configured in the LangGraph workflowagent = LangGraphAgent( name='openai-client-agent', description='You are an agent using external OpenAI API.', graph=workflow)
functions = [ { 'name': 'get_weather', 'description': 'Get weather information for a location', 'parameters': { 'type': 'object', 'properties': { 'location': { 'type': 'string', 'description': 'The city and state, e.g. San Francisco, CA' } }, 'required': ['location'] } }]response = client.chat.completions.create( model='gpt-4', messages=[ {'role': 'user', 'content': 'What is the weather in New York?'} ], functions=functions, function_call='auto')if response.choices[0].message.function_call: function_call = response.choices[0].message.function_call print('Function called:', function_call.name)