Canonical docs: https://apidoc.cometapi.com/integrations/langflow
Use this guide to connect Langflow to CometAPI by setting the base URL, API key, and model or provider options. Langflow is a visual framework for building agent and RAG workflows. Langflow includes a CometAPI component that calls CometAPI language models through OpenAI-compatible endpoints.
- Langflow Desktop, Langflow Cloud, or a self-hosted Langflow instance
- A CometAPI account with an active API key — get yours in the dashboard
- A model ID from the CometAPI Models page
In the Langflow canvas, open the component menu. Search for CometAPI, then add the CometAPI text generation component to your flow.
Select the CometAPI component. In the component inspection panel, enter your CometAPI API key in the API key field.
Set the model ID to a value from the CometAPI Models page. If the component can fetch models after you enter the API key, select the model ID from the model menu.
For a minimal test flow, add Chat Input and Chat Output components. Connect Chat Input to the CometAPI component input, then connect the CometAPI output to Chat Output.
Open Playground and send a short message. A successful chat response confirms that Langflow is calling CometAPI.
Change the CometAPI component output type to Language Model when another Langflow component needs an LLM input. This is useful for Agent, Prompt Template, and Smart Transform flows.
For direct chat, keep the default model response output and connect it to a Chat Output component.
After you test the flow in Playground, you can call the same Langflow flow from Python. The Python code calls your Langflow server. It does not send requests directly to CometAPI. Keep the CometAPI API key and model ID in the CometAPI component inside Langflow.
The REST API example sends a chat input to a flow ID or endpoint name:
import os
import requests
langflow_url = os.environ.get("LANGFLOW_URL", "http://localhost:7860")
langflow_api_key = os.environ["LANGFLOW_API_KEY"]
flow_id = os.environ["LANGFLOW_FLOW_ID"]
response = requests.post(
f"{langflow_url}/api/v1/run/{flow_id}",
headers={
"x-api-key": langflow_api_key,
"Content-Type": "application/json",
},
json={
"input_value": "Hello from CometAPI",
"input_type": "chat",
"output_type": "chat",
},
timeout=60,
)
response.raise_for_status()
print(response.json())For projects that use the Langflow Python SDK, install langflow-sdk and call the same flow through Client.run():
from langflow_sdk import Client
client = Client("http://localhost:7860", api_key="<LANGFLOW_API_KEY>")
response = client.run("FLOW_ID", input_value="Hello from CometAPI")
print(response.first_text_output())Replace FLOW_ID with the flow ID or endpoint name from Langflow. Replace <LANGFLOW_API_KEY> with your Langflow API key. This value is different from your CometAPI API key.
Update Langflow to a version that includes the CometAPI bundle. If your deployment hides some components, check the bundle settings or search under language model components.
Confirm that the CometAPI API key is valid and that the account has access to the selected model. You can also enter the model ID manually.
Check that the model ID matches CometAPI exactly and that the flow input is connected to the CometAPI component input.