Skip to content

Peer API

The Peers API allows you to interact with AI assistants (peers) in the Cognipeer platform. You can list available peers, get details about specific peers, and send messages to peers.

List Peers

Retrieves a list of all available peers.

Request

GET /v1/client/peer

Query Parameters

ParameterTypeRequiredDescription
limitintegerNoMaximum number of peers to return. Default: 10, Max: 100
skipintegerNoNumber of peers to skip. Default: 0
filterstringNoFilter peers by name or description

Response

json
{
  "status": "success",
  "data": [
    {
      "_id": "90aa68af-d5c4-4b60-b63e-b732db08bb46",
      "name": "Customer Support Assistant",
      "description": "Helps with product information and troubleshooting",
      "avatarUrl": "https://example.com/avatar.png",
      "createdAt": "2025-01-15T10:30:00.000Z",
      "updatedAt": "2025-04-01T14:22:33.000Z"
    },
    {
      "_id": "7b45cd12-a987-4321-b555-e789f0123456",
      "name": "Sales Specialist",
      "description": "Provides information about products and pricing",
      "avatarUrl": "https://example.com/sales-avatar.png",
      "createdAt": "2025-02-20T08:15:00.000Z",
      "updatedAt": "2025-03-25T11:42:15.000Z"
    }
  ]
}

Get Peer

Retrieves details about a specific peer.

Request

GET /v1/client/peer/{peerId}

Path Parameters

ParameterTypeRequiredDescription
peerIdstringYesID of the peer to retrieve

Response

json
{
  "status": "success",
  "data": {
    "_id": "90aa68af-d5c4-4b60-b63e-b732db08bb46",
    "name": "Customer Support Assistant",
    "description": "Helps with product information and troubleshooting",
    "avatarUrl": "https://example.com/avatar.png",
    "modelId": "gpt-4",
    "capabilities": ["answer_questions", "troubleshoot_issues", "explain_features"],
    "topicIds": ["customer-support", "product-information"],
    "datasourceIds": ["ds_12345", "ds_67890"],
    "createdAt": "2025-01-15T10:30:00.000Z",
    "updatedAt": "2025-04-01T14:22:33.000Z"
  }
}

Competition

Sends a message to a peer in competition mode, which creates a new conversation.

Request

POST /v1/client/peer/{peerId}/competition

Path Parameters

ParameterTypeRequiredDescription
peerIdstringYesID of the peer to send the message to

Request Body

json
{
  "content": "Tell me about your products",
  "responseFormat": "text",
  "responseSchema": {
    "type": "object",
    "properties": {
      "products": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "name": { "type": "string" },
            "description": { "type": "string" },
            "price": { "type": "number" }
          }
        }
      }
    }
  },
  "additionalContext": {
    "customerType": "enterprise",
    "region": "North America"
  }
}

Body Parameters

ParameterTypeRequiredDescription
contentstringYesThe message content
responseFormatstringNoFormat of the response. Can be 'text' (default) or 'json'
responseSchemaobjectNoJSON schema for structured responses (when responseFormat is 'json')
additionalContextobjectNoAdditional context to provide to the peer

Response

Text Response Format

json
{
  "status": "success",
  "data": {
    "conversationId": "7c8d9e0f-1a2b-3c4d-5e6f-7g8h9i0j1k2l",
    "content": "We offer several products designed for enterprise customers in North America...",
    "role": "ai",
    "createdAt": "2025-04-14T15:30:45.000Z"
  }
}

JSON Response Format

json
{
  "status": "success",
  "data": {
    "conversationId": "7c8d9e0f-1a2b-3c4d-5e6f-7g8h9i0j1k2l",
    "content": "Response in JSON format",
    "role": "ai",
    "output": {
      "products": [
        {
          "name": "Cognipeer Enterprise",
          "description": "Full-featured AI platform for enterprise",
          "price": 499.99
        },
        {
          "name": "Cognipeer Professional",
          "description": "Professional AI assistant solution",
          "price": 199.99
        }
      ]
    },
    "createdAt": "2025-04-14T15:30:45.000Z"
  }
}

Chat

Chat with a peer by sending a series of messages, creating a new conversation.

Request

POST /v1/client/peer/{peerId}/chat

Path Parameters

ParameterTypeRequiredDescription
peerIdstringYesID of the peer to chat with

Request Body

json
{
  "messages": [
    {
      "role": "user",
      "content": "Hello, who are you?"
    },
    {
      "role": "ai",
      "content": "I am an AI assistant from Cognipeer."
    },
    {
      "role": "user",
      "content": "What services do you offer?"
    }
  ],
  "responseFormat": "text",
  "additionalContext": {
    "customerType": "enterprise"
  }
}

Body Parameters

ParameterTypeRequiredDescription
messagesarrayYesArray of message objects, each with role ('user' or 'ai') and content
responseFormatstringNoFormat of the response. Can be 'text' (default) or 'json'
responseSchemaobjectNoJSON schema for structured responses (when responseFormat is 'json')
additionalContextobjectNoAdditional context to provide to the peer

Response

json
{
  "status": "success",
  "data": {
    "conversationId": "7c8d9e0f-1a2b-3c4d-5e6f-7g8h9i0j1k2l",
    "content": "We offer a range of AI services tailored for enterprise customers...",
    "role": "ai",
    "createdAt": "2025-04-14T15:30:45.000Z"
  }
}

Error Responses

Status CodeError CodeDescription
400invalid_requestThe request was malformed or missing required parameters
401unauthorizedThe API key is invalid or missing
403forbiddenThe API key does not have permission to perform this action
404peer_not_foundThe specified peer does not exist
429rate_limit_exceededToo many requests in a given amount of time
500server_errorAn unexpected error occurred on the server

Built with VitePress