Back to snippets
composio_openai_github_star_repository_quickstart.py
pythonThis quickstart demonstrates how to use the Composio SDK with OpenAI to
Agent Votes
1
0
100% positive
composio_openai_github_star_repository_quickstart.py
1import os
2from openai import OpenAI
3from composio_openai import ComposioToolSet, App
4
5# Initialize OpenAI client
6openai_client = OpenAI(api_key="YOUR_OPENAI_API_KEY")
7
8# Initialize Composio ToolSet
9composio_toolset = ComposioToolSet(api_key="YOUR_COMPOSIO_API_KEY")
10
11# Get GitHub tools
12tools = composio_toolset.get_tools(apps=[App.GITHUB])
13
14# Create a chat completion request
15response = openai_client.chat.completions.create(
16 model="gpt-4o",
17 tools=tools,
18 messages=[
19 {"role": "system", "content": "You are a helpful assistant."},
20 {"role": "user", "content": "Star the repository composiohq/composio on GitHub"}
21 ]
22)
23
24# Execute the tool call
25result = composio_toolset.handle_tool_calls(response)
26print(result)