diff --git a/docs/openapi/jan.yaml b/docs/openapi/jan.yaml
index 864c80fdf..ed80faf4f 100644
--- a/docs/openapi/jan.yaml
+++ b/docs/openapi/jan.yaml
@@ -1,11 +1,11 @@
----
openapi: 3.0.0
info:
title: API Reference
description: >
# Introduction
- Jan API is compatible with the [OpenAI API](https://platform.openai.com/docs/api-reference).
+ Jan API is compatible with the [OpenAI
+ API](https://platform.openai.com/docs/api-reference).
version: 0.1.8
contact:
name: Jan Discord
@@ -20,12 +20,12 @@ tags:
description: List and describe the various models available in the API.
- name: Chat
description: >
- Given a list of messages comprising a conversation, the model will
- return a response.
+ Given a list of messages comprising a conversation, the model will return
+ a response.
- name: Messages
description: >
- Messages capture a conversation's content. This can include the
- content from LLM responses and other metadata from [chat
+ Messages capture a conversation's content. This can include the content
+ from LLM responses and other metadata from [chat
completions](/specs/chats).
- name: Threads
- name: Assistants
@@ -49,16 +49,16 @@ paths:
summary: |
Create chat completion
description: >
- Creates a model response for the given chat conversation.
- Equivalent to OpenAI's create chat completion.
+ Creates a model response for the given chat conversation. Equivalent
+ to OpenAI's create chat completion.
requestBody:
content:
application/json:
schema:
$ref: specs/chat.yaml#/components/schemas/ChatCompletionRequest
responses:
- "200":
+ '200':
description: OK
content:
application/json:
@@ -100,12 +100,12 @@ paths:
- Models
summary: List models
description: >
- Lists the currently available models, and provides basic
- information about each one such as the owner and availability.
- Equivalent to OpenAI's list model.
+ Lists the currently available models, and provides basic information
+ about each one such as the owner and availability. Equivalent
+ to OpenAI's list model.
responses:
- "200":
+ '200':
description: OK
content:
application/json:
@@ -117,7 +117,7 @@ paths:
curl -X 'GET' \
'http://localhost:1337/v1/models' \
-H 'accept: application/json'
- "/models/download/{model_id}":
+ /models/download/{model_id}:
get:
operationId: downloadModel
tags:
@@ -135,7 +135,7 @@ paths:
description: |
The ID of the model to use for this request.
responses:
- "200":
+ '200':
description: OK
content:
application/json:
@@ -147,15 +147,15 @@ paths:
curl -X 'GET' \
'http://localhost:1337/v1/models/download/{model_id}' \
-H 'accept: application/json'
- "/models/{model_id}":
+ /models/{model_id}:
get:
operationId: retrieveModel
tags:
- Models
summary: Retrieve model
description: >
- Get a model instance, providing basic information about the model
- such as the owner and permissioning.
Equivalent to OpenAI's retrieve model.
parameters:
@@ -168,7 +168,7 @@ paths:
description: |
The ID of the model to use for this request.
responses:
- "200":
+ '200':
description: OK
content:
application/json:
@@ -199,7 +199,7 @@ paths:
description: |
The model id to delete
responses:
- "200":
+ '200':
description: OK
content:
application/json:
@@ -228,7 +228,7 @@ paths:
schema:
$ref: specs/threads.yaml#/components/schemas/CreateThreadObject
responses:
- "200":
+ '200':
description: Thread created successfully
content:
application/json:
@@ -237,8 +237,8 @@ paths:
x-codeSamples:
- lang: cURL
source: |
- curl -X POST http://localhost:1337/v1/threads \
- -H "Content-Type: application/json" \
+ curl -X POST http://localhost:1337/v1/threads \
+ -H "Content-Type: application/json" \
-d '{
"messages": [{
"role": "user",
@@ -249,6 +249,73 @@ paths:
"content": "How does AI work? Explain it in simple terms."
}]
}'
+ - lang: JavaScript
+ source: |-
+ const fetch = require('node-fetch');
+
+ fetch('http://localhost:1337/v1/threads', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json'
+ },
+ body: JSON.stringify({
+ messages: [
+ {
+ role: 'user',
+ content: 'Hello, what is AI?',
+ file_ids: ['file-abc123']
+ },
+ {
+ role: 'user',
+ content: 'How does AI work? Explain it in simple terms.'
+ }
+ ]
+ })
+ });
+ - lang: Node.js
+ source: |-
+ const fetch = require('node-fetch');
+
+ fetch('http://localhost:1337/v1/threads', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json'
+ },
+ body: JSON.stringify({
+ messages: [
+ {
+ role: 'user',
+ content: 'Hello, what is AI?',
+ file_ids: ['file-abc123']
+ },
+ {
+ role: 'user',
+ content: 'How does AI work? Explain it in simple terms.'
+ }
+ ]
+ })
+ });
+ - lang: Python
+ source: |-
+ import requests
+
+ url = 'http://localhost:1337/v1/threads'
+ payload = {
+ 'messages': [
+ {
+ 'role': 'user',
+ 'content': 'Hello, what is AI?',
+ 'file_ids': ['file-abc123']
+ },
+ {
+ 'role': 'user',
+ 'content': 'How does AI work? Explain it in simple terms.'
+ }
+ ]
+ }
+
+ response = requests.post(url, json=payload)
+ print(response.text)
get:
operationId: listThreads
tags:
@@ -257,7 +324,7 @@ paths:
description: |
Retrieves a list of all threads available in the system.
responses:
- "200":
+ '200':
description: List of threads retrieved successfully
content:
application/json:
@@ -282,10 +349,37 @@ paths:
metadata: {}
x-codeSamples:
- lang: cURL
- source: |
- curl http://localhost:1337/v1/threads \
- -H "Content-Type: application/json" \
- "/threads/{thread_id}":
+ source: |-
+ curl http://localhost:1337/v1/threads \
+ -H "Content-Type: application/json"
+ - lang: JavaScript
+ source: |-
+ const fetch = require('node-fetch');
+
+ fetch('http://localhost:1337/v1/threads', {
+ method: 'GET',
+ headers: {'Content-Type': 'application/json'}
+ }).then(res => res.json())
+ .then(json => console.log(json));
+ - lang: Node.js
+ source: |-
+ const fetch = require('node-fetch');
+
+ fetch('http://localhost:1337/v1/threads', {
+ method: 'GET',
+ headers: {'Content-Type': 'application/json'}
+ }).then(res => res.json())
+ .then(json => console.log(json));
+ - lang: Python
+ source: |-
+ import requests
+
+ url = 'http://localhost:1337/v1/threads'
+ headers = {'Content-Type': 'application/json'}
+
+ response = requests.get(url, headers=headers)
+ print(response.json())
+ /threads/{thread_id}:
get:
operationId: getThread
tags:
@@ -305,7 +399,7 @@ paths:
description: |
The ID of the thread to retrieve.
responses:
- "200":
+ '200':
description: Thread details retrieved successfully
content:
application/json:
@@ -345,7 +439,7 @@ paths:
items:
$ref: specs/threads.yaml#/components/schemas/ThreadMessageObject
responses:
- "200":
+ '200':
description: Thread modified successfully
content:
application/json:
@@ -384,7 +478,7 @@ paths:
description: |
The ID of the thread to be deleted.
responses:
- "200":
+ '200':
description: Thread deleted successfully
content:
application/json:
@@ -405,7 +499,7 @@ paths:
"https://platform.openai.com/docs/api-reference/assistants/listAssistants">
Equivalent to OpenAI's list assistants.
responses:
- "200":
+ '200':
description: List of assistants retrieved successfully
content:
application/json:
@@ -445,7 +539,7 @@ paths:
source: |
curl http://localhost:1337/v1/assistants \
-H "Content-Type: application/json" \
- "/assistants/{assistant_id}":
+ /assistants/{assistant_id}:
get:
operationId: getAssistant
tags:
@@ -465,18 +559,19 @@ paths:
description: |
The ID of the assistant to retrieve.
responses:
- "200":
+ '200':
description: null
content:
application/json:
schema:
- $ref: specs/assistants.yaml#/components/schemas/RetrieveAssistantResponse
+ $ref: >-
+ specs/assistants.yaml#/components/schemas/RetrieveAssistantResponse
x-codeSamples:
- lang: cURL
source: |
curl http://localhost:1337/v1/assistants/{assistant_id} \
-H "Content-Type: application/json" \
- "/threads/{thread_id}/messages":
+ /threads/{thread_id}/messages:
get:
operationId: listMessages
tags:
@@ -495,7 +590,7 @@ paths:
description: |
The ID of the thread from which to retrieve messages.
responses:
- "200":
+ '200':
description: List of messages retrieved successfully
content:
application/json:
@@ -547,7 +642,7 @@ paths:
- role
- content
responses:
- "200":
+ '200':
description: Message created successfully
content:
application/json:
@@ -562,7 +657,7 @@ paths:
"role": "user",
"content": "How does AI work? Explain it in simple terms."
}'
- "/threads/{thread_id}/messages/{message_id}":
+ /threads/{thread_id}/messages/{message_id}:
get:
operationId: retrieveMessage
tags:
@@ -589,7 +684,7 @@ paths:
description: |
The ID of the message to retrieve.
responses:
- "200":
+ '200':
description: OK
content:
application/json:
@@ -598,8 +693,8 @@ paths:
x-codeSamples:
- lang: cURL
source: >
- curl http://localhost:1337/v1/threads/{thread_id}/messages/{message_id}
- \
+ curl
+ http://localhost:1337/v1/threads/{thread_id}/messages/{message_id} \
-H "Content-Type: application/json"
x-webhooks:
ModelObject:
@@ -621,10 +716,9 @@ x-webhooks:
post:
summary: The assistant object
description: >
- Build assistants that can call models and use tools to perform
- tasks. Equivalent
- to OpenAI's assistants object.
+ Build assistants that can call models and use tools to perform tasks.
+
+ Equivalent to OpenAI's assistants object.
operationId: AssistantObjects
tags:
- Assistants
@@ -651,7 +745,8 @@ x-webhooks:
ThreadObject:
post:
summary: The thread object
- description: Represents a thread that contains messages. -
+ Represents a thread that contains messages.
Equivalent to OpenAI's thread object.
operationId: ThreadObject