# EbbotGPT API

### Unlock the Power of Advanced Language Models with Ebbot GPT API

Welcome to the Ebbot GPT API documentation. Our API offers seamless integration of service-optimized Large Language Models (LLMs) and Knowledge Management tools into your applications. With Ebbot GPT, you can harness sophisticated text generation capabilities and enhance your systems with cutting-edge AI technology. Explore our documentation to learn how to integrate and leverage the full potential of Ebbot GPT in your projects.

If you just want the open API documentation you can see it here:

{% embed url="<https://egpt.ebbot.eu/v1/api_docs/>" %}

### 1. API Key

To make requests to the API, you will need an API key. To obtain one, reach out to us at <helpme@ebbot.ai>.&#x20;

### 2. Tenant

A **tenant** is required for many requests. Tenants help separate token usage and datasets between different users. Typically, you’ll only need one tenant, but multiple tenants can be used if your business case requires it. Tenants are tied to your API key, ensuring your data remains secure.

### 3. Making a Request

* **ExternalId**: The ID you chose when creating the tenant.
* **Auth**: Authentication is done with a bearer token in the authorization header.\
  Example: `"Authorization: Bearer MyAPIKey123"`

#### 3.1 List Models

To list the available models:

```bash
curl -X GET "https://egpt.ebbot.eu/v1/models" \
 -H "accept: application/json" \
 -H "authorization: Bearer API-KEY"
```

#### 3.2 Create a tenant

Tenants are automatically created when a request with an unknown tenant is made. If you want to manually create a tenant then use this:

```bash
curl -X POST "https://egpt.ebbot.eu/v1/tenants/EXTERNAL-ID" \
 -H "accept: application/json"\
 -H "authorization: Bearer API-KEY" \
```

(Replace externalId with the id you want to add)

#### 3.3 List tenants

To list the tenants you have created:

```bash
curl -X GET "https://egpt.ebbot.eu/v1/tenants" \
 -H "accept: application/json"\
 -H "authorization: Bearer API-KEY" \
```

A response could look like this:

```json
[
"MyId1",
"MyId2",
"MyId3"
]
```

#### 3.4 Creating a tenant API key

You are able to create an API key for a tenant if you wish. The tenant is able with the key to: list models, create completions and get usage. If you want to create one you can do it like this:&#x20;

```bash
curl -X POST "https://egpt.ebbot.eu/v1/EXTERNAL_ID/tenant_keys/MyNewKey" \
 -H 'accept: application/json'\
 -H 'authorization: Bearer API_KEY' 
```

A response could look like this:

```json
{
"apiKey": "EeQBF$9h?M_0o_%[o&JU*u[[WN~^xoAQ%]ELeCN*61SS{F!Gk&DzZgEqSgQn>d-1",
"keyName": "MyNewKey",
"concurrentRequests": 10,
"tokenAllowance": 10000
}
```

**Make sure you save the API key as it will only be shown once!**

\
If you want to add some rate limit rules to the key you can add these as a query parameter:&#x20;

| Field            | Type    | Description                                                |
| ---------------- | ------- | ---------------------------------------------------------- |
| `concurrent`     | integer | How many requests can be made at the same time per minute. |
| `tokenAllowance` | integer | How many tokens can be used per minute.                    |

#### 3.5 List tenant API keys

If you want to list the API keys a tenant has you can use:

```bash
curl -X GET "https://egpt.ebbot.eu/v1/EXTERNAL_ID/tenant_keys" \
 -H 'accept: application/json'\
 -H 'authorization: Bearer API_KEY'
```

A response might look like this:

```json
[
  {
    "id": "cc756277-1633-4eab-9d3c-f75ed63a83f1",
    "keyName": "MyKey1",
    "created": "2024-09-24T09:39:06.547Z",
    "concurrentRequests": 10,
    "tokenAllowance": 10000
  },
  {
    "id": "586caf06-73c1-4665-868c-8f42d437a215",
    "keyName": "MyKey2",
    "created": "2024-05-23T09:39:06.547Z",
    "concurrentRequests": 15,
    "tokenAllowance": 5000
  }
]
```

#### 3.6 Revoke a tenant API key

To be able to revoke a tenant API key you can do it like this:&#x20;

```bash
curl -X DELETE "https://egpt.ebbot.eu/v1/EXTERNAL_ID/tenant_keys/MyNewKey" \
 -H 'accept: application/json'\
 -H 'authorization: Bearer API_KEY' 
```

#### 3.7 Creating a chat completion

This is where the magic happens. This is where you get a response from the bot. Here is a simple request with the bare necessities:

```bash
curl -X POST "https://egpt.ebbot.eu/v1/EXTERNAL-ID/chat/completion" \
 -H "accept: application/json"\
 -H "authorization: Bearer API-KEY"\
 -H "content-type: application/json" \
 -d '{"messages":[{"content":"You are a helpful assistant.","role":"system"},{"content":"Hello how are you?","role":"user"}]}' \
```

A response might look like this:

```json
{
  "response": {
    "id": "cmpl-1c6f8437c81f417983a137b00b986bda",
    "object": "chat.completion",
    "created": 18661963,
    "model": "ebbot_gpt-1.2.3",
    "choices": [
      {
        "index": 0,
        "message": {
          "role": "assistant",
          "content": "Hello! I'm an AI, so I don't have feelings like humans do, but I'm here to assist you with any questions or tasks you might have. How can I help you today?"
        },
        "finish_reason": "stop"
      }
    ],
    "usage": {
      "prompt_tokens": 28,
      "total_tokens": 121,
      "completion_tokens": 93
    },
    "pipeline": "egpt"
  },
  "documentSlicerMetadata": {
    "cutDocuments": 0
  },
  "sources": []
}
```

Request parameters

The following table describes the various parameters you can use when configuring your request. These parameters control different aspects of the response generation and the overall behavior of the API. Each parameter has specific functionality, ranging from controlling randomness in responses to enabling advanced retrieval mechanisms. Understanding these parameters will help you tailor the API's output to better meet your needs and ensure that you can leverage all available features effectively.

<table><thead><tr><th width="376.8927001953125">Field</th><th width="94.4354248046875">Type</th><th width="278.1612548828125">Description</th></tr></thead><tbody><tr><td><code>temperature</code></td><td>float</td><td>Controls the randomness of the response. Higher values make the output more random.</td></tr><tr><td><code>top_p</code></td><td>float</td><td>Top P filtering selects words with the highest probability that cumulatively reach a set threshold, ensuring diverse and unpredictable text generation. (Alternative to temperature)</td></tr><tr><td><code>top_k</code></td><td>integer</td><td>An integer from -1 to 100 that sets how many top tokens to consider during sampling. Higher values encourage diversity and less predictable results, while -1 considers all available tokens.</td></tr><tr><td><code>seed</code></td><td>integer</td><td>Attempts to make the answer deterministic.</td></tr><tr><td><code>maxTokens</code></td><td>integer</td><td>Maximum number of tokens used in the answer.</td></tr><tr><td><code>contentGuard</code></td><td>boolean</td><td>Flags inappropriate content by user and bot (e.g., sexual content, violence).</td></tr><tr><td><code>contentGuardConfig</code></td><td>object</td><td>Configurations for the content guard</td></tr><tr><td><code>contentGuardConfig.categories</code></td><td>array</td><td>You can set what categories should be blocked by content guard. Example: "Privacy", "Hate". It needs to be one of our predefined categories in order to work.</td></tr><tr><td><code>promptGuard</code></td><td>boolean</td><td>Flags if user trying is trying alter the bots behavior.</td></tr><tr><td><code>rag</code></td><td>object</td><td>Retrieval Augmented Generation (embedder)</td></tr><tr><td><code>rag.output</code></td><td>string</td><td>Placeholder for the word that will be replaced by the response from the embedder in the system prompt (e.g., <code>{documents}</code>)</td></tr><tr><td><code>rag.dataSetId</code></td><td>string (UUID)</td><td>The ID of the dataset that should be used.</td></tr><tr><td><code>rag.returnSources</code></td><td>boolean</td><td>If the sources of the datasets should be returned.</td></tr><tr><td><code>rag.searchDefinitions</code></td><td>array</td><td>List of search definitions.</td></tr><tr><td><code>rag.references</code></td><td>boolean</td><td>If references should be added. This will allow the model to add reference tags to the response.</td></tr><tr><td><code>rag.searchDefinitions.rnrK</code></td><td>integer</td><td>Retrieve and rerank involves first pulling relevant information from a large dataset and then sorting it by importance or relevance. <strong>(Experimental)</strong></td></tr><tr><td><code>rag.searchDefinitions.topK</code></td><td>number</td><td>Selects the top 'K' items from a list based on the highest scores or most relevance.</td></tr><tr><td><code>rag.searchDefinitions.numberOfMessages</code></td><td>integer</td><td>Number of messages to use from the conversation.</td></tr><tr><td><code>rag.searchDefinitions.filter</code></td><td>string</td><td>Filters based on specific roles (user, assistant, both or const).</td></tr><tr><td><code>rag.searchDefinitions.searchString</code></td><td>string</td><td>If you want to search for a specific string instead of a whole message</td></tr><tr><td><code>model</code></td><td>string</td><td>The model to be used for the request.</td></tr><tr><td><code>messages</code></td><td>array</td><td>The conversation history.</td></tr><tr><td><code>messages[].content</code></td><td>string</td><td>The content of the message.</td></tr><tr><td><code>messages[].role</code></td><td>enum</td><td>Who sent the message (e.g., <code>system</code>, <code>user</code>, <code>assistant, tool</code>).</td></tr><tr><td><code>messages[].reasoning_content</code></td><td>string</td><td>Agent reasoning.</td></tr><tr><td><code>messages[].tool_calls</code></td><td>array</td><td>Contains the tools used by the agent.</td></tr><tr><td><code>messages[].refrences</code></td><td>array</td><td>These are references to rag documents. The rag references option has to be turned on.</td></tr><tr><td><code>messages[].refrences[].id</code></td><td>string</td><td>The id of the reference.</td></tr><tr><td><code>messages[].refrences[].position</code></td><td>object</td><td>Contains the position of the reference.</td></tr><tr><td><code>messages[].refrences[].position.start</code></td><td>integer</td><td>The start position of the reference.</td></tr><tr><td><code>messages[].refrences[].position.end</code></td><td>integer</td><td>The end position of the reference.</td></tr><tr><td><code>messages[].refrences[].content</code></td><td>string</td><td>The content in between the tags of the reference. </td></tr><tr><td><code>messages[].tool_call_id</code></td><td>string</td><td>The ID of the tool call</td></tr><tr><td><code>messages[].tool_calls[].id</code></td><td>string</td><td>The tool id.</td></tr><tr><td><code>messages[].tool_calls[].type</code></td><td>enum</td><td>The type of the tool. This can only be 'function'</td></tr><tr><td><code>messages[].tool_calls[].function</code></td><td>object</td><td>Information about the tool called.</td></tr><tr><td><code>messages[].tool_calls[].function.name</code></td><td>string</td><td>The name of the tool called.</td></tr><tr><td><code>messages[].tool_calls[].function.arguments</code></td><td>string</td><td>The arguments of the tool called.</td></tr><tr><td><code>response</code></td><td>object</td><td>Settings for the response type.</td></tr><tr><td><code>response.type</code></td><td>string</td><td>The type can be 'polled' or 'immediate' depending on if you are doing high or low prio requests.</td></tr><tr><td><code>response_format</code></td><td>object</td><td>This is for structured output.</td></tr><tr><td><code>response_format.type</code></td><td>enum</td><td>The type of structured output. It can be 'json_schema' or 'text'</td></tr><tr><td><code>response_format.json_schema</code></td><td>object</td><td>This is the definition of the json schema that the model will follow.</td></tr><tr><td><code>response_format.json_schema.description</code></td><td>string</td><td>The description of what the json schema represents.</td></tr><tr><td><code>response_format.json_schema.name</code></td><td>string</td><td>The name of the schema.</td></tr><tr><td><code>response_format.json_schema.schema</code></td><td>object (json)</td><td>This is the schema the model will follow.</td></tr><tr><td><code>response_format.json_schema.strict</code></td><td>boolean</td><td>If the schema should be followed strictly.</td></tr><tr><td><code>repairURLs</code></td><td>boolean</td><td>This will look though the generated response for urls and replaces them with urls from the system prompt. It will do a similarity check to get the best match.</td></tr><tr><td><code>mcp</code></td><td>string</td><td>This is the url for an mcp server.</td></tr><tr><td><code>tools</code></td><td>array</td><td>This is where you define tools that the model can use.</td></tr><tr><td><code>tools.type</code></td><td>enum</td><td>This can only be 'function'.</td></tr><tr><td><code>tools.function</code></td><td>object</td><td>This is the definition of the tool call.</td></tr><tr><td><code>tools.function.description</code></td><td>string</td><td>The description of the tool call. Write a good description for best results.</td></tr><tr><td><code>tools.function.name</code></td><td>string</td><td>The name of the tool. Write a good name for best results.</td></tr><tr><td><code>tools.function.parameters</code></td><td>object (json)</td><td>This is the parameters of the tool.</td></tr><tr><td><code>tools.function.strict</code></td><td>boolean</td><td>If the parameters should be followed strictly.</td></tr></tbody></table>

When you have gotten a completion you can add the response from the bot to the array of messages and then continue the conversation with your user input. It could look like this:

```json
{
  "messages": [
    {
      "content": "You are a helpful assistant.",
      "role": "system"
    },
    {
      "content": "Hello how are you?",
      "role": "user"
    },
    {
      "content": "Hello! I'm an AI, so I don't have feelings like humans do, but I'm here to assist you with any questions or tasks you might have. How can I help you today?",
      "role": "assistant"
    },
    {
      "content": "Okay nice! There is a problem with my tv remote. How can I get it fixed?",
      "role": "user"
    }
  ]
}
```

### 4. Get token usage

To get the token usage between two dates:

```bash
curl -X GET "https://egpt.ebbot.eu/v1/EXTERNAL-ID/usage?from=2024-05-01+12%3A00%3A00.000%2B00&to=2024-09-01+12%3A00%3A00.000%2B00" \
 -H "accept: application/json"\
 -H "authorization: Bearer API-KEY" 
```

The response might look something like this:

```json
{
  "usage": [
    {
      "day": "2024-06-28T00:00:00.000Z",
      "sum": 2224
    },
    {
      "day": "2024-07-17T00:00:00.000Z",
      "sum": 1435
    }
  ],
  "pages": {
    "currentPage": 1,
    "totalPages": 1
  }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ebbot.ai/ebbot-docs/developer-resources/ebbotgpt/ebbotgpt-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
