Skip to main content
POST
/
agent
/
{agentId}
/
query
Query Agent
curl --request POST \
  --url http://sandbox.mintlify.com/agent/{agentId}/query \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "prompt": "<string>"
}
'
{}
Queries a registered AI agent via the Nevermined Proxy or directly, using a valid payment plan and signature-based access token. This method allows subscribers to send input to an agent’s endpoint while securely redeeming credits in the background.

Example Usage

// Step 1: Get access credentials for the agent
const accessCredentials = await payments.query.getAgentHTTPOptions(planId, agentId)

// Step 2: Query the agent with the credentials
const result = await payments.query(agentId, accessCredentials, { prompt: "Write a smart contract." })

// OR use with standard fetch
const options = await payments.query.getAgentHTTPOptions(planId, agentId)
const response = await fetch(agentEndpoint, {
  method: 'POST',
  headers: options.headers,
  body: JSON.stringify({ prompt: "Write a smart contract." })
})

Parameters

  • planId: The ID of the payment plan the subscriber has purchased
  • agentId: The ID of the agent being queried
  • accessCredentials: Auth credentials object containing:
    • accessToken: JWT token for authentication
    • neverminedProxyUri: Proxy URI for requests
  • payload: Request payload, typically includes a prompt or other structured input

Response

The access credentials object structure:
{
  "accessToken": "eJyNj0sKgDAURP9lJQ....",
  "neverminedProxyUri": "https://proxy.testing.nevermined.app"
}

Notes

  • Nevermined will automatically:
    • Validate the subscriber’s plan and credits
    • Send the request to the agent’s registered endpoint
    • Redeem the appropriate number of credits (defined by the plan)
  • Fails with a 402 if the subscriber is unauthorized

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

agentId
string
required

The unique identifier of the agent to query

Body

application/json

Query payload

prompt
string

Response

Query successful

The response is of type object.