Skip to content

Commit

Permalink
Merge pull request #178 from NillionNetwork/feat/nilai
Browse files Browse the repository at this point in the history
chore: test
  • Loading branch information
crypblizz8 authored Jan 29, 2025
2 parents 78b9a43 + 9289f5a commit 454d515
Show file tree
Hide file tree
Showing 18 changed files with 1,382 additions and 18 deletions.
585 changes: 585 additions & 0 deletions apispec/nilai-api.yaml

Large diffs are not rendered by default.

104 changes: 104 additions & 0 deletions docs/api/nilai/chat-completion-v-1-chat-completions-post.api.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
---
id: chat-completion-v-1-chat-completions-post
title: "Chat Completion"
description: ":::info"
sidebar_label: "Chat Completion"
hide_title: true
hide_table_of_contents: true
api: eJztWd1vGzcS/1fYzUPbQFrJaoJe9dIqitPzIXEMy9eiiAyb2qUkxlySJbmSdYb+95shuR+yZCFN0IfDJQ/RZnc4n78ZzkweEkcXNhl+SMZL6pLrTpIzmxmuHVcyGSZTORwOuZyrqSTw5w1jgswNY8QpUlr4WTJye86FAPJBf/DyllBLKHHMOvKKUcMMuVJ3THo+U/j5lUlmqGNAlIFEkqlCC4bSiGFWKwlM50YVnvPojBQqZyLFk13y/Llhfz5/PiTjvZN/ligxU9JRLrlckIJZSxcMlJF5YEKsZhmf84ziGRsYgg0GOY5KkCcdfmQ5WmYIWm0KT0y+c0ujysWS/PPq6qIybMlozsz3gdElc6WRFnm9KYUIxtUWrblbRi1U6XTpOiAD1CPWgQALcm3Ha5qZjXZqYahe8oxYvpAU+DK0/9mzZ+QyGoq/3LACVPaGvCvhJZeZKHNGpJJdVmi3IQJYEzWvnVGTBldsIAheKXw/KbVWxllSlMJx8Gx1igQ3WPKd3VjHio53D6hrLbCn0n3faBfNHUNolKyVQxHdRQx8DuC4b0cPSTxGoksK5gz4A1+P296gQmy8R4BFAxVlyIqZOqyVKhdGZaA+ImHimAZuJyn5jQqeI/a4hBDUqNHUUBDKDFANUjjK4A1rEIQyQux0zXUqf0hJjeUKp7VeU/kiJVeGZnc+qqX2Y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ImmeJQlfrL9L3hyEt0=
sidebar_class_name: "post api-method"
info_path: api/nilai/nilai
custom_edit_url: null
---

import MethodEndpoint from "@theme/ApiExplorer/MethodEndpoint";
import ParamsDetails from "@theme/ParamsDetails";
import RequestSchema from "@theme/RequestSchema";
import StatusCodes from "@theme/StatusCodes";
import OperationTabs from "@theme/OperationTabs";
import TabItem from "@theme/TabItem";
import Heading from "@theme/Heading";

<Heading
as={"h1"}
className={"openapi__heading"}
children={"Chat Completion"}
>
</Heading>

<MethodEndpoint
method={"post"}
path={"/v1/chat/completions"}
context={"endpoint"}
>

</MethodEndpoint>




:::info
Feel free to use the `Nillion2025` as a test Bearer Token
:::

Generate a chat completion response from the AI model.

- **req**: Chat completion request containing messages and model specifications
- **user**: Authenticated user information (through HTTP Bearer header)
- **Returns**: Full chat response with model output, usage statistics, and cryptographic signature

### Request Requirements
- Must include non-empty list of messages
- Must specify a model
- Supports multiple message formats (system, user, assistant)

### Response Components
- Model-generated text completion
- Token usage metrics
- Cryptographically signed response for verification

### Processing Steps
1. Validate input request parameters
2. Prepare messages for model processing
3. Generate AI model response
4. Track and update token usage
5. Cryptographically sign the response

### Potential HTTP Errors
- **400 Bad Request**:
- Missing messages list
- No model specified
- **500 Internal Server Error**:
- Model fails to generate a response

<Heading
id={"request"}
as={"h2"}
className={"openapi-tabs__heading"}
children={"Request"}
>
</Heading>

<ParamsDetails
parameters={undefined}
>

</ParamsDetails>

<RequestSchema
title={"Body"}
body={{"content":{"application/json":{"schema":{"allOf":[{"properties":{"model":{"type":"string","title":"Model"},"messages":{"items":{"properties":{"content":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Content"},"refusal":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Refusal"},"role":{"type":"string","enum":["system","user","assistant"],"title":"Role"},"audio":{"anyOf":[{"properties":{"id":{"type":"string","title":"Id"},"data":{"type":"string","title":"Data"},"expires_at":{"type":"integer","title":"Expires At"},"transcript":{"type":"string","title":"Transcript"}},"additionalProperties":true,"type":"object","required":["id","data","expires_at","transcript"],"title":"ChatCompletionAudio"},{"type":"null"}]},"function_call":{"anyOf":[{"properties":{"arguments":{"type":"string","title":"Arguments"},"name":{"type":"string","title":"Name"}},"additionalProperties":true,"type":"object","required":["arguments","name"],"title":"FunctionCall"},{"type":"null"}]},"tool_calls":{"anyOf":[{"items":{"properties":{"id":{"type":"string","title":"Id"},"function":{"properties":{"arguments":{"type":"string","title":"Arguments"},"name":{"type":"string","title":"Name"}},"additionalProperties":true,"type":"object","required":["arguments","name"],"title":"Function"},"type":{"type":"string","const":"function","title":"Type"}},"additionalProperties":true,"type":"object","required":["id","function","type"],"title":"ChatCompletionMessageToolCall"},"type":"array"},{"type":"null"}],"title":"Tool Calls"}},"additionalProperties":true,"type":"object","required":["role"],"title":"Message"},"type":"array","title":"Messages"},"temperature":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Temperature","default":0.2},"top_p":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Top P","default":0.95},"max_tokens":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Max Tokens","default":2048},"stream":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Stream","default":false},"nilrag":{"anyOf":[{"type":"object"},{"type":"null"}],"title":"Nilrag","default":{}}},"type":"object","required":["model","messages"],"title":"ChatRequest"},{"example":{"model":"meta-llama/Llama-3.2-1B-Instruct","messages":[{"role":"system","content":"You are a helpful assistant"},{"role":"user","content":"What is your name?"}],"temperature":0.2,"top_p":0.95,"max_tokens":2048,"stream":false,"nilrag":{}}}]}}}}}
>

</RequestSchema>

<StatusCodes
id={undefined}
label={undefined}
responses={{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"properties":{"detail":{"items":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"}}}}}}
>

</StatusCodes>



79 changes: 79 additions & 0 deletions docs/api/nilai/get-attestation-v-1-attestation-report-get.api.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
id: get-attestation-v-1-attestation-report-get
title: "Attestation"
description: ":::info"
sidebar_label: "Attestation"
hide_title: true
hide_table_of_contents: true
api: eJztVm1v2zYQ/itX9UO3wJaSAEMxf1m9LM28DW1QpxuGuYhpmbaYyCRHUnY1I/99z0l0IiVFUQzYtwYBLEr38tzx7rnbJ0GsfTL6KxmHIH0QQRmdfBgkS+lzp2xzHCUzPRqNlF6ZmSb8vZaypJWTkoKhyuOnkDR/o8oS4qfHp9/NSXgSxBbpRymcdHRlbqVu7MzwcyG1dCJICOWutsGsnbCFykk8wCAnrXEhZfkhHR3BkTs6GtG4gjsdVA79Jbt3xNDcptX6JhTOVOuCfr66ujx4L6RYSvdta+idDJXTvrHVcbeUQajSE0wRjG5VLmkrnVqxJwgwjufPn/d0fmp12O68ka2VXl/fyno+ostqUSIiHBqT/Tj7hqGd2+q6Ezz0zy7fk9Rb5YzeIN6nKusnKhefVWnhT2VeORVqemOCnOlLZ7YKt/0In3XGrAj/fLUxGy88Eh3kutEWetl1lSaDxFi+U7iaLFEzaxm66K63J71je7nXkIKmk94a7SUqcZ+cHh/zT78Cp1WeS+9XVUnvojD0cgM8OrC4sLaMkWY3nnX2ic8LuRH8hHAALqjWQ++m+EWorYQTHxxewm5QoeQXvx8E6VcI3sFhP+Wf0z2zVbdUWHv95doXj7WhHmXN4kbmbdb+rpSTS27ffkhPgT51/uHBWcfRfXLv+G+Q+Fgt8LFPuKPahsLxwx0sbGQoTLxt+LAiFDhk25Os4ypr7zphaw5AfWOsciVEixCsH2WZVqVQQ/Hy5fepbnkk1TLsjLtNHpPRFKW3MB+71ZcwlgPUKd96e9FdwPe5ZpeMpRHDedEKcLTMI41kTAwobTx5AmCmx5rGE9qYJXiwaQ5UiC1FYBYia3YSt0KLmhpIckCo0xWaDKQlShw2tgpQSduWpHPhaxpfTuisVNy1kRxjz/4h8CryrKlcI6g01fyMsuZa+IEunBSBtNz5Z/SnqSgXmkQVDHNiLsqypnWHcVs3pVo44Wo2dlOBqAWt5I682tgSLR+k9emBM16Dvy5rXDUz3laW3Ewgvfl8vhC+gAxNNC67LBu6eGulZpTRpXEzbZWFn1YEylpYNbz/PASgxhPdj4UmuuixhTvTn9R7iGuoqFdMqW/rhOvJrOv0Y/1PFk2kTBA0xJ21HoaG0qx9Hh68IbZu9L+IrZg2NZBdoYzax/+YDG0398l4FSEFY0qffTrE4fpT2enA+N8yxHnhrmmr/3FuxquA0RrNo54HDOwFgirElusMZI3CW1U651rmyu8XXihQsxtxi+GjAknuAtQ5jxgn8kA7FYq24ieHCeRTTC30nZPQ0xVMcmqZB3nTKBBOCRzPZsx3sLLxb1fTVrNPNQ2/oA/jCIE37notNrHp+Tu7nVY2MhfmiGK+ujFeprlYgDHMq64lsAfmj2TqfDA1tgIsQ6fpMUz0CW+326Wi+Zwat86irs9+m5ydv5meD1kHNpkuW9Y5Tk/aV9b4gOi7bnpE3yOr/cOM/LrFfd3ivmCLi1MyyI8hw0xTzebS1O4+zndsGycQ7K8XccZjDheoTxba78GH8r0r7+74NXrU8RqBx61wSix4wmKLgEJzrc1S0OxjyRi7nuWu24qyYjBPlrve7nFxfsVwKsZ2P+XjVB8cHth6/CR03bENmI1EU9qAOoggAp/hCGvQv4X3tco=
sidebar_class_name: "get api-method"
info_path: api/nilai/nilai
custom_edit_url: null
---

import MethodEndpoint from "@theme/ApiExplorer/MethodEndpoint";
import ParamsDetails from "@theme/ParamsDetails";
import RequestSchema from "@theme/RequestSchema";
import StatusCodes from "@theme/StatusCodes";
import OperationTabs from "@theme/OperationTabs";
import TabItem from "@theme/TabItem";
import Heading from "@theme/Heading";

<Heading
as={"h1"}
className={"openapi__heading"}
children={"Attestation"}
>
</Heading>

<MethodEndpoint
method={"get"}
path={"/v1/attestation/report"}
context={"endpoint"}
>

</MethodEndpoint>




:::info
Feel free to use the `Nillion2025` as a test Bearer Token
:::

Generate a cryptographic attestation report.

- **user**: Authenticated user information (through HTTP Bearer header)
- **Returns**: Attestation details for service verification

### Attestation Details
- `verifying_key`: Public key for cryptographic verification
- `cpu_attestation`: CPU environment verification
- `gpu_attestation`: GPU environment verification

### Security Note
Provides cryptographic proof of the service's integrity and environment.

<ParamsDetails
parameters={undefined}
>

</ParamsDetails>

<RequestSchema
title={"Body"}
body={undefined}
>

</RequestSchema>

<StatusCodes
id={undefined}
label={undefined}
responses={{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"properties":{"verifying_key":{"type":"string","title":"Verifying Key"},"cpu_attestation":{"type":"string","title":"Cpu Attestation"},"gpu_attestation":{"type":"string","title":"Gpu Attestation"}},"type":"object","required":["verifying_key","cpu_attestation","gpu_attestation"],"title":"AttestationResponse"}}}}}}
>

</StatusCodes>



77 changes: 77 additions & 0 deletions docs/api/nilai/get-models-v-1-models-get.api.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
id: get-models-v-1-models-get
title: "Models"
description: ":::info"
sidebar_label: "Models"
hide_title: true
hide_table_of_contents: true
api: eJztVlFv2zYQ/itX9WFtYMtJgKGYgWH1mjRzkaTFnHUY6qKhZdpiIpMaSdnRDP/3fUdKie2meRjQt+UhlqiPd98d777jOvFi7pL+p+TCTGWRfO4kU+kyq0qvjE76yVj3+32lZ2asCX9vpSxoZqUkb6hy+MklXV+qogD8+PD4x2sSjgR56Tz9KoWVlq7MrdTBzhg/5wpfRFGQWApViEkhacGuHSkdrLnaeblIGdulgwM4sQcHfRpU+Ki9yoSXU3ZtiWnZhWCm9MLn1lTznH67uvrQes6lmEr7Mhr6XfrKase2TlTGm4Stycy+IsKenz9/Tqd3YlEWcqyvr6/L2ueG1wlmrJJL6ajgSB7d3wT0M4mVUJ7m0n+JSy+Y98tgMekkppQ2sB9OkekH1JflUfuERQCtdKXRTu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ziH7LzUWrr3sT+P4q8f+N8DveCJux4uWd72EIqHCrCYe9bobgp2R5BGAzBjGqchwhL6/XkAz5hy02G15GGVuernhcCquYTBiu2BBSEObmray5snB1LLkwl6KowlTfvyvujOSz06vmLrE1CJvB12kf2Hp7R9D1lm3QDIhQAqDaaUh4focj3A7+BY11aLQ=
sidebar_class_name: "get api-method"
info_path: api/nilai/nilai
custom_edit_url: null
---

import MethodEndpoint from "@theme/ApiExplorer/MethodEndpoint";
import ParamsDetails from "@theme/ParamsDetails";
import RequestSchema from "@theme/RequestSchema";
import StatusCodes from "@theme/StatusCodes";
import OperationTabs from "@theme/OperationTabs";
import TabItem from "@theme/TabItem";
import Heading from "@theme/Heading";

<Heading
as={"h1"}
className={"openapi__heading"}
children={"Models"}
>
</Heading>

<MethodEndpoint
method={"get"}
path={"/v1/models"}
context={"endpoint"}
>

</MethodEndpoint>




:::info
Feel free to use the `Nillion2025` as a test Bearer Token
:::

List all available models in the system.

- **user**: Authenticated user information (through HTTP Bearer header)
- **Returns**: Dictionary of available models

### Example
```python
# Retrieves list of available models
models = await get_models(user)
```

<ParamsDetails
parameters={undefined}
>

</ParamsDetails>

<RequestSchema
title={"Body"}
body={undefined}
>

</RequestSchema>

<StatusCodes
id={undefined}
label={undefined}
responses={{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"items":{"properties":{"id":{"type":"string","title":"Id"},"name":{"type":"string","title":"Name"},"version":{"type":"string","title":"Version"},"description":{"type":"string","title":"Description"},"author":{"type":"string","title":"Author"},"license":{"type":"string","title":"License"},"source":{"type":"string","title":"Source"},"supported_features":{"items":{"type":"string"},"type":"array","title":"Supported Features"}},"type":"object","required":["name","version","description","author","license","source","supported_features"],"title":"ModelMetadata"},"type":"array","title":"Response Get Models V1 Models Get"}}}}}}
>

</StatusCodes>



77 changes: 77 additions & 0 deletions docs/api/nilai/get-usage-v-1-usage-get.api.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
id: get-usage-v-1-usage-get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7IzbinX7PXYqBVH5F1A1TZHAb9yzu18VdGm8ILJeRc9YT6r8j+wLTiTHFCzsG/a7LlnKFbG/JhpPuZQVMqIHxaWApcGMFGPDTUVg9yXuGpxNYMGsoNIji0Nh4zVBf0bS7XtiZp+QkSX1ofWkOuY2J7LuKeR9KT01XxSgyMvapEZ2LkSBdoIIKiteiPbmdRsd8pbWkUOIrrYY3B2pvXpPcbUF22qm2IY+oX7S0yp+rP5IaoiYGJm1sWbBQluzOAnP7bU1jK0Z/S98zge+B5IhtlF4/IfJUMVsk4yPtUtOa2mT/SG2p/uy03Djm2WI8kK3JnT/bm66E4fbYA2P/dwix95iUDmfU5/hdoSNNylVGubXbuO5HHt2xh9ww8OVDegWYJ/TDDY8dWwhXB46vhcuGW5cMTvXeO8MoJ4qEZJSS1OPluUcw5Hox5uRotkGZmYvJoOguT1q/HzBe1jvbGiNbr3is/rS03syOyiLQhsaZri4CZpX99pCnPIxTgz9sYmE0wMXPqBF8AmqWxBZsJP4CCG2B95isYi5fx1rM01qXZv82js9Ox+ctUkHMWlchqlzFB+Ho0Jbh9E3zFzV43VrTC2f1tH/f4L8d36C1CTk4NElSBlCUUl9ayxrxryO5sfULutfkznWm06XS5wvcGXkakXH2POGmBgf59wIPibGuqZtKyTHk+wDVJsNOSJBWZL1Z79Otuj7y9kwosWZnNmwZs2SrfVDY2vCNaqBjW56Cd8w6GqrdsJn0O80qz8BAmxjOg==
sidebar_class_name: "get api-method"
info_path: api/nilai/nilai
custom_edit_url: null
---

import MethodEndpoint from "@theme/ApiExplorer/MethodEndpoint";
import ParamsDetails from "@theme/ParamsDetails";
import RequestSchema from "@theme/RequestSchema";
import StatusCodes from "@theme/StatusCodes";
import OperationTabs from "@theme/OperationTabs";
import TabItem from "@theme/TabItem";
import Heading from "@theme/Heading";

<Heading
as={"h1"}
className={"openapi__heading"}
children={"Usage"}
>
</Heading>

<MethodEndpoint
method={"get"}
path={"/v1/usage"}
context={"endpoint"}
>

</MethodEndpoint>




:::info
Feel free to use the `Nillion2025` as a test Bearer Token
:::

Retrieve the current token usage for the authenticated user.

- **user**: Authenticated user information (through HTTP Bearer header)
- **Returns**: Usage statistics for the user's token consumption

### Example
```python
# Retrieves token usage for the logged-in user
usage = await get_usage(user)
```

<ParamsDetails
parameters={undefined}
>

</ParamsDetails>

<RequestSchema
title={"Body"}
body={undefined}
>

</RequestSchema>

<StatusCodes
id={undefined}
label={undefined}
responses={{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"properties":{"completion_tokens":{"type":"integer","title":"Completion Tokens"},"prompt_tokens":{"type":"integer","title":"Prompt Tokens"},"total_tokens":{"type":"integer","title":"Total Tokens"},"completion_tokens_details":{"anyOf":[{"properties":{"accepted_prediction_tokens":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Accepted Prediction Tokens"},"audio_tokens":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Audio Tokens"},"reasoning_tokens":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Reasoning Tokens"},"rejected_prediction_tokens":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Rejected Prediction Tokens"}},"additionalProperties":true,"type":"object","title":"CompletionTokensDetails"},{"type":"null"}]},"prompt_tokens_details":{"anyOf":[{"properties":{"audio_tokens":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Audio Tokens"},"cached_tokens":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Cached Tokens"}},"additionalProperties":true,"type":"object","title":"PromptTokensDetails"},{"type":"null"}]}},"additionalProperties":true,"type":"object","required":["completion_tokens","prompt_tokens","total_tokens"],"title":"CompletionUsage"}}}}}}
>

</StatusCodes>



Loading

0 comments on commit 454d515

Please sign in to comment.