Custom API

The Custom API node in Stack AI allows you to connect your workflow to any external API endpoint. This powerful feature enables you to fetch, process, and utilize data from third-party services, internal APIs, or any web-accessible resource, making your AI workflows highly flexible and extensible.
Key Features
Universal API Integration: Connect to any RESTful API using GET, POST, PUT, or DELETE methods.
Custom Headers and Authentication: Add custom headers for authentication or content-type requirements.
Dynamic Payloads: Pass data from previous nodes (like user input or AI-generated content) directly into your API requests.
Seamless Data Flow: Use API responses as inputs for downstream nodes, such as LLMs, Python code, or output nodes.
How to Configure the Custom API Node
1. Add the Custom API Node to Your Workflow
In the Stack AI workflow builder, drag the Custom API node onto your canvas.
2. Set the API Endpoint
Enter the full URL of the API you want to connect to in the URL field (e.g.,
https://api.example.com/data
).
3. Choose the HTTP Method
Select the HTTP method you need: GET, POST, PUT, or DELETE.
4. Configure Headers (Optional)
Add any required headers in JSON format. For example, to add an API key:
{ "Authorization": "Bearer YOUR_API_KEY", "Content-Type": "application/json" }
5. Set the Request Body or Query Parameters
For POST or PUT requests, the request body or query parameters will come from the previous node connected to it.
For GET requests, add query parameters directly to the URL or use the information from the previous node connected to it.
6. Connect Upstream Nodes
Link nodes like Input, Python, or LLM to the Custom API node to pass dynamic data into your API call.
7. Use the API Response
The output of the Custom API node can be referenced in downstream nodes for further processing, summarization, or display.
Best Practices for Using the Custom API Node
Test Your API Calls: Use tools like Postman to verify your API endpoint and payload before integrating.
Handle Authentication Securely: Store sensitive keys in environment variables or secure storage.
Use Dynamic References: Leverage Stack AI’s node referencing (e.g.,
{in-0}
) to make your API calls dynamic and context-aware.Error Handling: Check the API response for errors and handle them gracefully in your workflow.
Frequently Asked Questions
Q: Can I use the Custom API node with authenticated APIs? A: Yes! Just add the required authentication headers in the headers field.
Q: How do I pass data from previous nodes into my API request?
A: Use curly braces with the node ID (e.g., {in-0}
or {python-0}
) in your request body or URL.
Q: What happens to the API response? A: The response is available as the output of the Custom API node and can be used in any downstream node.
Conclusion
The Custom API node in Stack AI is your gateway to integrating any external data source or service into your AI workflows. By following the steps above, you can easily connect, fetch, and process data from any API, unlocking endless automation and AI-powered possibilities.
Last updated
Was this helpful?