Updating an Integral
The Integral is where you create your API handlers. A single Integral can handle multiple traditional API requests as defined by your prompt
NOTE
You need to setup your environment before creating Integral
How to Update an Integral
Updating an Integral involves modifying the configuration file and then running the push command
First make sure you have the latest version by pulling remote version
reasonai api pull
Next open the config file of the API you want to edit in your editor ./reason/integrals/yourAPI/yourAPI.json
TIP
You can also edit the Integral on the web console
In this example, we want to change the model from open ai to anthropic, without changing anything else. We will simply update line 4 from gpt-4o-mini
to claude-3-5-sonnet-20240620
{
"name": "charactersAPI",
"instruction": "When asked to get a list of characters, you call the getCharacters function. When given Futurama character name, you call the getcharacterbyname function.return results in JSON format",
"model": "gpt-4o-mini",
"responseFormat": "json_object",
"tools": [
{
"name": "getCharacterByName",
"type": "function"
},
{
"name": "getCharacters",
"type": "function"
}
]
}
{
"name": "charactersAPI",
"instruction": "When asked to get a list of characters, you call the getCharacters function. When given Futurama character name, you call the getcharacterbyname function.return results in JSON format",
"model": "gpt-4o-mini",
"model": "claude-3-5-sonnet-20240620",
"responseFormat": "json_object",
"tools": [
{
"name": "getCharacterByName",
"type": "function",
},
{
"name": "getCharacters",
"type": "function",
},
],
}
After making the changes, save the file and proceed to deployment.
But first, we want to see all the changes we have locally. To achieve this we run the status command
:
reasonai api status
We should get something like:
# ...
> charactersAPI Updated locally // [!code focus]
# ... other integrals
Now we are really ready to deploy:
reasonai api push
That's it. Your Integral is deployed and live
Testing your API
curl https://reasonai.dev/api/v1/request \
-X POST \
-H "Authorization: Bearer <your api key here>" \
-d '{
"apiId": "<copy from ./reason/.meta.json>",
"messages": [
{
"role": "user",
"content": "what is the starsign of a person born in April 1992"
}
]
}'
You should receive results similar to:
{
"id": "<your-api-id>",
"threadId": "thread_6zY61bNiZX08Yt15MVolgaue",
"messages": {
"id": "msg_54vENtcnHHojV8sBL7HkB7ol",
"role": "assistant",
"content": [
{
"type": "text",
"text": "{\"sign\":\"Aries\"}"
}
]
}
}
:::
TIP
To learn more on effective prompt generations, click here
To see the full API reference for creating an Integral, click here
Next Steps
You've reached the end of the tutorial, you can also:
- start from the begining
- look at the API Reference
- Or the CLI Reference for more commands and configuration ``