fetch-logo
ConceptsConceptsGuidesGuidesExamplesExamplesReferencesReferencesAPIsAPIs
GitHub (opens in a new tab)
  • Examples
      • Create your first agent
      • Interval task with Agents
      • Multiple agents communication
      • Local Network Interaction
      • Agents communication
      • Agents storage
      • Table booking service with Agents
      • Cleaning service with Agents
      • Send tokens with Agents
      • Verify messages with Agents
      • Communicating with other agents wallet
      • Agents communication using Agentverse Mailbox service
      • Agents Broadcast
      • Agents Name Service
      • Query an agent using a proxy API
      • Register a dice roll agent as a Function
      • Register a coin toss agent as a Function
      • Register a local agent as a Function
      • Using News API to build network of Primary and Secondary functions
      • Locally Hosted Agent with LangChain Integration
      • Hugging face API agent as a Function
      • On Query decorator example
      • Agents and Functions Creation using APIs
      • Adding Secret to agent using Agentverse API
      • React app with agents 'on_query' decorator
      • Open Dialogue Chit-Chat
      • Predefined Dialogue Chit-Chat
      • Chat API example
      • DeltaV Dialogue Chit-Chat
  • Examples
      • Create your first agent
      • Interval task with Agents
      • Multiple agents communication
      • Local Network Interaction
      • Agents communication
      • Agents storage
      • Table booking service with Agents
      • Cleaning service with Agents
      • Send tokens with Agents
      • Verify messages with Agents
      • Communicating with other agents wallet
      • Agents communication using Agentverse Mailbox service
      • Agents Broadcast
      • Agents Name Service
      • Query an agent using a proxy API
      • Register a dice roll agent as a Function
      • Register a coin toss agent as a Function
      • Register a local agent as a Function
      • Using News API to build network of Primary and Secondary functions
      • Locally Hosted Agent with LangChain Integration
      • Hugging face API agent as a Function
      • On Query decorator example
      • Agents and Functions Creation using APIs
      • Adding Secret to agent using Agentverse API
        • Introduction
        • Prerequisites
        • Steps to get API Tokens
        • Script to add secret to agent
        • Steps to add secret to agent using API
      • React app with agents 'on_query' decorator
      • Open Dialogue Chit-Chat
      • Predefined Dialogue Chit-Chat
      • Chat API example
      • DeltaV Dialogue Chit-Chat
Examples
Intermediate topics
Adding Secret to agent using Agentverse API

Adding Secret to agent using Agentverse API

Introduction

This example provides details on how to use the hosting API to add a secret to an agent. Secrets are added to an agent to ensure they remain hidden from end users and to enhance security.

Prerequisites

  • Before you begin, ensure you have the following:
    • Python version greater than 3.9 and less than 3.11.
    • The requests library installed. You can install it using pip install requests.
    • Agentverse ↗️ (opens in a new tab) Credentials.

Steps to get API Tokens

  • Go to Profile section in Agentverse ↗️ (opens in a new tab).
  • Click on button + New API Key.
  • Give name to your API key.
  • Click on write for Access to all resources in Agentverse and click on Generate API Key

Script to add secret to agent

# Importing libraries
import requests
 
# Decode the refresh token
token = 'Bearer fauna_access_token'
 
# Take name of agent and secret details from user
address = input('Please enter address of agent to which you want to add the secret:  ')
name = input("Please enter name for your secret:  ")
secret = input("Please enter value for your secret:  ")
 
# Create Payload for post request
data = {
    'address': address,
    'name': name,
    'secret': secret
}
 
# Post request to add secret to agent
response_agent = requests.post("https://agentverse.ai/v1/hosting/secrets", json=data, headers={"Authorization": token})
 
 
# Check if the response code is 200
if response_agent.status_code == 200:
    print("Secret added successfully.")
else:
    print(f"Failed to add secret. Status code: {response_agent.status_code}")

Steps to add secret to agent using API

  • Navigate to directory where agent-secret script are located using terminal.
  • Open Agentverse ↗️ (opens in a new tab) and generate API keys.
  • Open script in editor and replace fauna_access_token.
  • Run agent-secret.py file using python agent-secret.py file.
  • Provide agent's address, secret name and secret value.
  • Try using secret name in script instead of value, for example APIKey in our case.

Expected Output

  • Provide details and response on basis of secret added or not to the agent in agentverse.

Was this page helpful?

Agents and Functions Creation using APIsReact app with agents 'on_query' decorator
footer-logo

Main website

Integrations

Events

We’re hiring!

Twitter (opens in a new tab)Telegram (opens in a new tab)Discord (opens in a new tab)GitHub (opens in a new tab)Youtube (opens in a new tab)LinkedIn (opens in a new tab)Reddit (opens in a new tab)
Sign up for developer updates