It is common for API documentation to provide example cURL commands for testing API endpoints. There are several approaches to converting cURL to inputs to the API node for use in Runchat.

Using Copy-Paste

To make an API request in Runchat you will need an endpoint URL, a request method (GET, POST, PUT, PATCH or DELETE), a header object (that usually contains things like authorization keys and content type specifications) and body text. cURL examples contain all of this information, and if you are familiar with cURL and http requests in general it is not hard to copy paste what you need. For example, our method is in yellow, url is in green, header is in blue and body is in orange. However, it is easy to make syntax errors when copy pasting even if you know what you’re doing, so it is often more reliable to automate this translation.

image.png

Using Functions

https://runchat.app/editor?id=29de392d-ee15-45e7-a922-8389171a1028

An approach that works reliably with most language models (both from Gemini and served through OpenRouter) is to use function calling to format our output data from the prompt node for an api request. First, paste your cURL command example into an input Text node and connect this to the context input of a Prompt node. Then, in your prompt, ask for an API request from the cURL code.

If you try running the prompt now, you will get arbitrarily structured output - you might get a text explanation, or a JSON object in the wrong format. This is because the Prompt node doesn’t yet know how to call our API Node function. To let the Prompt know how to use the API node, we can add it to the list of Tools. Expand the settings on your prompt node and then click in the “Add runchats as tools…” input and type API Node. Click on the blue button to add the API node as a tool. Now try running the prompt node again. You should see a function call as the output:

image.png

You might notice that the inputs object now contains all of the properties we need to make a request to our API node. You can use the Extract Function Inputs Runchat node (from the Objects library) to go and retrieve these properties and map them to output parameters to easily connect to the API node. Go ahead and add an API node and connect the matching parameters. Run the API node to make a request.

If your request requires api keys, you will need to manually enter these in to the header object. Disconnect the header input and then make changes to the header as required.

Using Formats

If you have access to Runchat Pro or are using OpenAI models with OpenRouter you can also ask the prompt node to produce output in the required format. The downside of this approach is that because Gemini requires exact schemas without optional properties, you will need to precisely specify the keys of your header object, or leave out the header entirely and manually add it. Create a prompt node and change the Format type to Object. Then enter keys for url, method and body. Run the same prompt as above (”convert this cURL command to an API request” or something similar) and you should see the appropriate outputs. You can then use a Get Parameters node from the Objects library to convert this object to output parameters to connect directly to the API node.