agentic platform - working with REST API

When working with the REST API call in agentic platform, it can be challenging because some of the docs are not updated. 

To help you get the REST API right, you can curl this endpoint It will list out all methods and parameter to pass to other services. 

curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json" https://us-central1-aiplatform.googleapis.com/v1/projects/project-YOUR-PROJECT-ID/locations/us-central1/reasoningEngines/REASONING_ENGINE_ID

Some details include :-

classMethods - has been deprecated - Use async_get_session instead

list_sessions - has been deprecated - Use async_list_sessions instead

create_session - has been deprecated - Use async_create_session instead


To get sessions 

curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json" https://us-central1-aiplatform.clients6.google.com/v1beta1/projects/YOUR-PROJECT-ID/locations/us-central1/reasoningEngines/YOUR-REASONING-ENGINE/sessions

To create sessions

curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -X POST -H "Content-Type: applica

tion/json" https://us-central1-aiplatform.clients6.google.com/v1beta1/projects/YOUR-PROJECT-IDlocations/us-central1/reasoningEngines/YOUR-REASONING-ENGINE/sessions -d '{userId: "demo-user"}'

Or you can use this 

 curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -X POST -H "Content-Type: application/json" https://us-central1-aiplatform.clients6.google.com/v1beta1/projects/YOUR-PROJECT-ID/locations/us-central1/reasoningEngines/YOUR-REASONING-ENGINE:query -d '

   {"class_method": "create_session", "input": {"user_id": "test2"}}'

🔥  To post query to the endpoint (please note: we are using streamQuery instead of query

This query is a static example, you need to replace with the actual user_id and session_id you got in previous steps. 

curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -X POST -H "Content-Type: application/json" https://us-central1-aiplatform.googleapis.com/v1/projects/YOUR-PROJECT-ID/locations/us-central1/reasoningEngines/YOUR-REASONING-ENGINE:streamQuery?alt=sse -d '{

"class_method": "stream_query",

"input": {

"user_id": "your-user-id-step1",

"session_id": "session-id-step-1",

"message": "What data do you have?"

}

}'

An example output shown here:- 








Comments

Popular posts from this blog

vllm : Failed to infer device type

android studio kotlin source is null error

gemini cli getting file not defined error