PageSourceSearch

https://innovationlab.fetch.ai/resources/assets/js/42261674.0972b178.js

js fetch.ai collected 2026-09-24 09:40:11 UTC 13,504 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkinnovation_labs=self.webpackChunkinnovation_labs||[]).push([[2757],{47095:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>o,contentTitle:()=>a,default:()=>h,frontMatter:()=>l,metadata:()=>t,toc:()=>d});const t=JSON.parse('{"id":"asione/asi1-api-reference","title":"ASI1 API Reference","description":"This API Reference describes the RESTful and streaming interfaces of the ASI:One platform.","source":"@site/versioned_docs/version-1.0.5/asione/api-reference.md","sourceDirName":"asione","slug":"/asione/asi1-api-reference","permalink":"/resources/docs/asione/asi1-api-reference","draft":false,"unlisted":false,"tags":[],"version":"1.0.5","frontMatter":{"id":"asi1-api-reference","title":"ASI1 API Reference","sidebar_label":"API Reference"}}');var i=s(74848),r=s(28453);const l={id:"asi1-api-reference",title:"ASI1 API Reference",sidebar_label:"API Reference"},a="ASI API Reference",o={},d=[{value:"Introduction",id:"introduction",level:2},{value:"OpenAI Compatibility",id:"openai-compatibility",level:2},{value:"Authorization",id:"authorization",level:2},{value:"Base URL",id:"base-url",level:2},{value:"Endpoints",id:"endpoints",level:2},{value:"Chat Completions",id:"chat-completions",level:3},{value:"Request Parameters",id:"request-parameters",level:4},{value:"Message Object",id:"message-object",level:4},{value:"Example Request",id:"example-request",level:4},{value:"Response Format",id:"response-format",level:4},{value:"Choice Object",id:"choice-object",level:4},{value:"Example Response (Non-streaming)",id:"example-response-non-streaming",level:4},{value:"Streaming Responses",id:"streaming-responses",level:4},{value:"Error Handling",id:"error-handling",level:2},{value:"Rate Limits",id:"rate-limits",level:2},{value:"Best Practices",id:"best-practices",level:2}];function c(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",li:"li",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsxs)(n.h1,{id:"asi-api-reference",children:["ASI",":One"," API Reference"]})}),"\n",(0,i.jsxs)(n.p,{children:["This API Reference describes the RESTful and streaming interfaces of the ASI",":One"," platform."]}),"\n",(0,i.jsx)(n.h2,{id:"introduction",children:"Introduction"}),"\n",(0,i.jsxs)(n.p,{children:["ASI",":One"," provides a powerful API that allows developers to integrate advanced agentic AI capabilities into their applications. The API is designed to be easy to use while providing access to the full range of ASI",":One","'s capabilities."]}),"\n",(0,i.jsx)(n.h2,{id:"openai-compatibility",children:"OpenAI Compatibility"}),"\n",(0,i.jsxs)(n.p,{children:["Where possible, the ASI",":One"," API conforms to the OpenAI API specification. This means that users can often plug the ASI",":One"," API into existing code that uses the OpenAI API with minimal changes."]}),"\n",(0,i.jsx)(n.h2,{id:"authorization",children:"Authorization"}),"\n",(0,i.jsxs)(n.p,{children:["API keys can be created from your account when you log into ASI",":One",". Authorization is done by adding the following header into your requests:"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{children:"Authorization: Bearer <api token>\n"})}),"\n",(0,i.jsx)(n.p,{children:"Remember your API key is a secret, do not share it with anyone. If you need to revoke access for a particular key, simply log into your account and delete it from your profile."}),"\n",(0,i.jsx)(n.h2,{id:"base-url",children:"Base URL"}),"\n",(0,i.jsx)(n.p,{children:"All API requests should be made to the following base URL:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{children:"https://api.asi1.ai/v1\n"})}),"\n",(0,i.jsx)(n.h2,{id:"endpoints",children:"Endpoints"}
1),"\n",(0,i.jsx)(n.h3,{id:"chat-completions",children:"Chat Completions"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{children:"POST /chat/completions\n"})}),"\n",(0,i.jsx)(n.p,{children:"Creates a model response for the given chat conversation."}),"\n",(0,i.jsx)(n.h4,{id:"request-parameters",children:"Request Parameters"}),"\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{children:"Parameter"}),(0,i.jsx)(n.th,{children:"Type"}),(0,i.jsx)(n.th,{children:"Required"}),(0,i.jsx)(n.th,{children:"Description"})]})}),(0,i.jsxs)(n.tbody,{children:[(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"model"}),(0,i.jsx)(n.td,{children:"string"}),(0,i.jsx)(n.td,{children:"Yes"}),(0,i.jsx)(n.td,{children:'ID of the model to use. Currently, only "asi1" is available.'})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"messages"}),(0,i.jsx)(n.td,{children:"array"}),(0,i.jsx)(n.td,{children:"Yes"}),(0,i.jsx)(n.td,{children:"An array of message objects representing the conversation history."})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"temperature"}),(0,i.jsx)(n.td,{children:"number"}),(0,i.jsx)(n.td,{children:"No"}),(0,i.jsx)(n.td,{children:"What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. Default is 1.0."})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"stream"}),(0,i.jsx)(n.td,{children:"boolean"}),(0,i.jsx)(n.td,{children:"No"}),(0,i.jsx)(n.td,{children:"If set to true, partial message deltas will be sent as they become available. Default is false."})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"max_tokens"}),(0,i.jsx)(n.td,{children:"integer"}),(0,i.jsx)(n.td,{children:"No"}),(0,i.jsx)(n.td,{children:"The maximum number of tokens that can be generated in the chat completion. This can be used to control costs for text generated via API."})]})]})]}),"\n",(0,i.jsx)(n.h4,{id:"message-object",children:"Message Object"}),"\n",(0,i.jsxs)(n.p,{children:["Each message in the ",(0,i.jsx)(n.code,{children:"messages"})," array should have the following structure:"]}),"\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{children:"Field"}),(0,i.jsx)(n.th,{children:"Type"}),(0,i.jsx)(n.th,{children:"Description"})]})}),(0,i.jsxs)(n.tbody,{children:[(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"role"}),(0,i.jsx)(n.td,{children:"string"}),(0,i.jsx)(n.td,{children:'The role of the message author. Must be one of "system", "user", or "assistant".'})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"content"}),(0,i.jsx)(n.td,{children:"string"}),(0,i.jsx)(n.td,{children:"The content of the message."})]})]})]}),"\n",(0,i.jsx)(n.h4,{id:"example-request",children:"Example Request"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-json",children:'{\n  "model": "asi1",\n  "messages": [\n    {\n      "role": "system",\n      "content": "You are a helpful assistant specialized in Web3 technologies."\n    },\n    {\n      "role": "user",\n      "content": "Explain the concept of decentralized AI."\n    }\n  ],\n  "temperature": 0.7,\n  "stream": false,\n  "max_tokens": 500\n}\n'})}),"\n",(0,i.jsx)(n.h4,{id:"response-format",children:"Response Format"}),"\n",(0,i.jsx)(n.p,{children:"The API returns a JSON object with the following structure:"}),"\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{children:"Field"}),(0,i.jsx)(n.th,{children:"Type"}),(0,i.jsx)(n.th,{children:"Description"})]})}),(0,i.jsxs)(n.tbody,{children:[(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"id"}),(0,i.jsx)(n.td,{children:"string"}),(0,i.jsx)(n.td,{children:"The completion request ID."})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"model"}),(0,i.jsx)(n.td,{children:"string"}),(0,i.jsx)(n.td,{children:"The name of the model being used."})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"thought"}),(0,i.jsx)(n.td,{children:"string"}),(0,i.jsx)(n.td,{children:"(Optional) The thoughts that were generated as part of the chat completion request. Only present when streaming is enabled."})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"choices"}),(0,i.jsx)(n.td,{children:"array"}),(0,i.jsx)(n.td,{children:"An array of completion choices."})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"usage"}),(0,i.jsx)(n.td,{children:"object"}),(0,i.jsx)(n.td,{children:"(Optional) Information about token usage."})]})]})]}),"\n",(0,i.jsx)(n.h4,{id:"choice-object",children:"Choice Object"}),"\n",(0,i.jsxs)(n.p,{children:["Each choice in the ",(0,i.jsx)(n.code,{children:"choices"})," array has the following structure:"]}),"\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{children:"Field"}),(0,i.jsx)(n.th,{children:"Type"}),(0,i.jsx)(n.th,{children:"Description"})]})}),(0,i.jsxs)(n.tbody,{children:[(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"index"}),(0,i.jsx)(n.td,{children:"integer"}),(0,i.jsx)(n.td,{children:"The index of the choice in the array."})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"delta"}),(0,i.jsx)(n.td,{children:"object"}),(0,i.jsx)(n.td,{children:"(When streaming) Contains the incremental content being streamed."})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"finish_reason"}),(0,i.jsx)(n.td,{children:"string"}),(0,i.jsx)(n.td,{children:'The reason the model stopped generating text. Can be "stop", "length", etc.'})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"stop_reason"}),(0,i.jsx)(n.td,{children:"string"}),(0,i.jsx)(n.td,{children:"Additional information about why generation stopped."})]})]})]}),"\n",(0,i.jsx)(n.h4,{id:"example-response-non-streaming",children:"Example Response (Non-streaming)"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-json",children:'{\n  "id": "id_comqjiusZjAoyuXlh",\n  "object": "chat.completion",\n  "model": "asi1",\n  "choices": [\n    {\n      "index": 0,\n      "message": {\n        "role": "assistant",\n        "content": "Decentralized AI refers to artificial intelligence systems that operate on distributed networks rather than centralized servers. This approach aligns with Web3 principles by removing central points of control and enabling more democratic access to AI capabilities..."\n      },\n      "finish_reason": "stop",\n      "stop_reason": "stop"\n    }\n  ],\n  "usage": {\n    "prompt_tokens": 435,\n    "completion_tokens": 391,\n    "total_tokens": 826\n  }\n}\n'})}),"\n",(0,i.jsx)(n.h4,{id:"streaming-responses",children:"Streaming Responses"}),"\n",(0,i.jsxs)(n.p,{children:["When ",(0,i.jsx)(n.code,{children:"stream"})," is set to ",(0,i.jsx)(n.code,{children:"true"}),", the API will send a series of server-sent events (SSE) with partial completions as they become available. Each event is prefixed with ",(0,i.jsx)(n.code,{children:"data: "})," and contains a JSON object with incremental updates."]}),"\n",(0,i.jsxs)(n.p,{children:["The stream is terminated with a ",(0,i.jsx)(n.code,{children:"data: [DONE]"})," message."]}),"\n",(0,i.jsx)(n.h2,{id:"error-handling",children:"Error Handling"}),"\n",(0,i.jsx)(n.p,{children:"The API uses standard HTTP status codes to indicate the success or failure of requests:"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"200: Success"}),"\n",(0,i.jsx)(n.li,{children:"400: Bad Request (invalid parameters)"}),"\n",(0,i.jsx)(n.li,{children:"401: Unauthorized (invalid API key)"}),"\n",(0,i.jsx)(n.li,{children:"422: Unprocessable Entity (valid parameters but request cannot be processed)"}),"\n",(0,i.jsx)(n.li,{children:"429: Too Many Requests (rate limit exceeded)"}),"\n",(0,i.jsx)(n.li,{children:"500: Internal Server Error"}),"\n"]}),"\n",(0,i.jsxs)(n.p,{children:["Error responses include a JSON object with an ",(0,i.jsx)(n.code,{children:"error"})," field containing details about the error."]}),"\n",(0,i.jsx)(n.h2,{id:"rate-limits",children:"Rate Limits"}),"\n",(0,i.jsx)(n.p,{children:"API usage is subject to rate limits based on your account tier. If you exceed these limits, you'll receive a 429 status code. The response headers include information about your current rate limit status."}),"\n",(0,i.jsx)(n.h2,{id:"best-practices",children:"Best Practices"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"Store your API key securely and never expose it in client-side code."}),"\n",(0,i.jsx)(n.li,{children:"Implement proper error handling to gracefully handle API errors."}),"\n",(0,i.jsx)(n.li,{children:"For long-running conversations, consider maintaining context on your side to reduce token usage."}),"\n",(0,i.jsx)(n.li,{children:"Use streaming for more responsive user interfaces when generating longer responses."}),"\n"]}),"\n",(0,i.jsxs)(n.p,{children:["For more detailed examples of how to use the API, see the ",(0,i.jsx)(n.a,{href:"/resources/docs/asione/asi1-chat-completion",children:"Chat 
1Completion"})," guide."]})]})}function h(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(c,{...e})}):c(e)}},28453:(e,n,s)=>{s.d(n,{R:()=>l,x:()=>a});var t=s(96540);const i={},r=t.createContext(i);function l(e){const n=t.useContext(r);return t.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function a(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:l(e.components),t.createElement(r.Provider,{value:n},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.