In today’s data-driven world, the ability to create AI-powered agents that can retrieve and process real-time information has become increasingly valuable. This is particularly evident in industries such as finance, healthcare, and e-commerce, where timely insights can significantly impact decision-making and customer experiences.
Whether you’re a developer, data scientist, or AI enthusiast, DigitalOcean’s GenAI Platform offers a streamlined solution for building intelligent agents without the need for complex infrastructure. By leveraging GenAI Platform, you can focus on creating AI models that drive meaningful interactions and insights, rather than worrying about the underlying infrastructure required to support them.
In this tutorial, we’ll walk through the process of creating an AI agent that can answer questions about your DigitalOcean account by retrieving data from the DigitalOcean API in real-time. The agent will be able to provide information about Droplets (virtual machines), including their IDs, status, and other details.
What makes DigitalOcean’s approach particularly compelling is how it enables the creation of agents that can connect directly to APIs and deliver up-to-the-minute answers. This capability opens up a world of possibilities for more interactive and informed AI solutions across various applications.
AI agents like this are particularly useful for a wide range of use cases, including but not limited to:
By integrating AI agents with APIs, we create a powerful combination that enhances decision-making capabilities through access to real-time data. This approach allows businesses to build more responsive and intelligent systems that can adapt to changing conditions. However, like any technology solution, there are trade-offs to consider when implementing AI agents with API integration.
First, we’ll create a function that the language model can call to retrieve data from the DigitalOcean API:
In the DigitalOcean control panel, navigate to Functions and click “Create Namespace”.
Select a data center location (e.g., Toronto)
Use the doctl
command line tool to connect to your namespace:
Initialize a sample Python project:
Once the sample project is initialized, you’ll need to:
Modify the project file to define the Python runtime and set security headers.
Create an environment file for your DigitalOcean API token (this is so the Function can retrieve data from your DigitalOcean account).
Replace the hello world sample with your API function code that retrieves droplet information.
Create a build script for importing Python dependencies.
Deploy the function to make it available in the cloud.
After deployment, you can test your function through the web interface to ensure it returns the expected information about your droplets.
You can find a complete example with all the required code and configuration in this repository.
You can create your AI agent either through the web interface or using the API:
The web interface provides a user-friendly way to create and manage AI agents. This option is ideal for users who prefer a graphical interface over command-line interactions.
You are a helpful assistant that provides information about DigitalOcean customer accounts. Your role is to help users understand their account details, team information, resource usage, and account status.
Llama 3.3 Instruct-70B
)Using the API provides a programmatic way to create and manage AI agents, offering flexibility and automation that may not be available through the web interface. This approach is particularly useful for developers and organizations that require custom integrations, large-scale deployments, or automated agent management.
You can also create an agent programmatically using the DigitalOcean API. Here’s an example using curl
:
Required parameters:
name
: A descriptive name for your agentmodel_uuid
: The UUID of the language model to useinstruction
: System prompt that defines the agent’s purpose and behaviorregion
: The datacenter region where the agent will be deployedOptional parameters:
description
: A brief description of the agent’s purposeproject_id
: The project to associate the agent withtags
: Array of tags for organizing your agentsMake sure to replace $API_TOKEN
with your actual API token and YOUR_PROJECT_ID
with your project’s ID.
Connecting your function to the AI agent is essential for enabling real-time data retrieval and intelligent decision-making. This step ensures that your agent can access up-to-date information directly from your DigitalOcean environment, enhancing its capabilities beyond static responses.
The final step is to link your function to the agent. You can do this either through the web interface or using the API:
The web interface provides a user-friendly way to create and manage AI agents without requiring extensive programming knowledge. This option is ideal for users who prefer a graphical interface over command-line interactions.
Call this function when the user asks about their DigitalOcean droplets, virtual machines, instances, or servers. Use this function to retrieve information about one or more droplets in a DigitalOcean account.
Using the API provides a programmatic way to create and manage AI agents, offering flexibility and automation that may not be available through the web interface. This approach is particularly useful for developers and organizations that require custom integrations, large-scale deployments, or automated agent management.
You can also connect functions to your agent programmatically using the DigitalOcean API. Here’s an example using curl
:
Required parameters:
agent_uuid
: The UUID of your agentfunction_name
: A name for the function routeinput_schema
: JSON schema defining the function’s input parametersoutput_schema
: JSON schema defining the function’s return valuesfaas_namespace
: Your Functions namespace IDfaas_name
: The path to your function (namespace/function-name)Optional parameters:
description
: Instructions for when the agent should use this functionThe input schema specifies parameters the agent can send to your function (like droplet ID).
The output schema helps the agent interpret the returned data.
With everything set up, you can now ask your agent questions about your DigitalOcean account:
The agent will call your function, retrieve the information from the DigitalOcean API in real-time, and provide you with an intelligent response.
While testing, you may encounter some common issues:
doctl serverless logs
to debug runtime issues.The primary benefit is the ability to create AI agents that can connect to APIs and deliver real-time information without the need for complex infrastructure. This platform offers a streamlined path to building intelligent, API-connected agents, making advanced AI capabilities accessible to developers of all skill levels.
Yes, the platform is versatile and can be applied to a wide range of use cases. For instance, you can leverage GenAI Platform to build internal tools that streamline business operations, such as automating workflows or generating reports.
Additionally, you can use the platform to develop customer-facing applications that provide personalized experiences, like chatbots or virtual assistants. Furthermore, GenAI is suitable for data analysis solutions that require real-time data and insights, enabling you to make informed decisions or identify trends. The possibilities are vast, and the platform’s flexibility allows you to adapt it to your specific needs and goals.
The integration of serverless functions with large language models on DigitalOcean’s GenAI Platform offers a significant advantage. It enables developers of all skill levels to access advanced AI capabilities, providing a simplified and efficient way to build intelligent agents that can seamlessly connect to APIs. This combination empowers developers to focus on creating innovative AI solutions without worrying about the underlying infrastructure, making it an ideal choice for a wide range of applications.
To embark on your AI agent-building journey with DigitalOcean’s GenAI platform, begin by immersing yourself in the platform’s comprehensive documentation and engaging tutorials. These resources will provide a solid foundation for understanding the platform’s capabilities and best practices. Next, dive into hands-on experimentation by creating simple AI agents, which will allow you to grasp the fundamental concepts and workflows. As you gain confidence and experience, you can progress to more intricate and ambitious projects, unlocking the full potential of the GenAI Platform.
DigitalOcean’s GenAI platform offers a powerful yet accessible way to build AI agents that can connect to APIs and deliver real-time information. This approach eliminates the need for complex infrastructure while enabling sophisticated AI solutions.
The example we’ve walked through is just the beginning. You can apply the same principles to create agents that interact with any API, providing real-time data and insights for various use cases. Whether you’re looking to build internal tools, customer-facing applications, or data analysis solutions, DigitalOcean’s GenAI platform offers a streamlined path to intelligent, API-connected agents.
By combining the flexibility of serverless functions with the power of large language models, DigitalOcean has created a platform that makes advanced AI capabilities accessible to developers of all skill levels.
Continue building with DigitalOcean Gen AI Platform.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!