Context
  1. FaceTo-AI Tool Docs
Context
  • FaceTo-AI Tool Docs
    • Getting Started
    • Server APIs
    • Security
    • About ChatAPI
    • API Docs
      • Get FaceTo-AI Room Link
  1. FaceTo-AI Tool Docs

About ChatAPI

What is ChatAPI#

It is a parameter to get the video link, Get FaceTo-AI Room Link
ChatAPI is a third-party interface for interfacing with ChatGPT.
This interface enables video custom dialog streams.
Feel free to customize your interface with ChatGPT's prompt, temperature, top_p, n, etc., and wonderful things will happen.
This interface needs to be developed by your engineers

Why We Support ChatAPI#

Our FaceTo-AI talks directly to chatapi, but our prompt is special and can only be used in our scenario.
In order to achieve the diversity of video conversations, we have specifically developed this interface, and through the customization of third-party interfaces, things get interesting.
We hope that we can realize the diversity and infinite possibilities of video dialogue by opening third-party interfaces, and we will realize the scenarios you want you to think of.

How To Design ChatAPI#

1.1 Communication protocol#

HTTPS

1.2 Request method#

Only the POST method is supported to initiate requests.

1.3 Character encoding#

The BASE64 encoding of HTTP communication and message adopts UTF-8 character set encoding format.

1.4 Context-Type#

application/json

1.5 Parameter#

Request Body
nametypedescriptionmark
messagesarrayvideo conversationsrequired
message
nametypedescriptionmark
rolestringChat message role defined by the OpenAI API.required The role of the author of this message. One of system, user, or assistant
contentstringThe contents of the message.required
namestringThis property isn't in the official documentation, but it's in the documentation for the official library for python:
the documentation for the official library for python:
How_to_count_tokens_with_tiktoken.ipynb
example
{
    "messages": [
        {
            "role": "user",
            "content": "hello"
        }
    ]
}

1.6 Return Value#

The return value must be returned as a stream
Accept: text/event-stream
example
data:{"content":"I"}

data:{"content":" am"}

data:{"content":" an"}

data:{"content":" AI"}

data:{"content":" language"}

data:{"content":" model"}

data:{"content":" created"}

data:{"content":" by"}

data:{"content":" Open"}

data:{"content":"AI"}

data:{"content":"."}

data:{"content":" I"}

data:{"content":" am"}

data:{"content":" designed"}

data:{"content":" to"}

data:{"content":" assist"}

data:{"content":" and"}

data:{"content":" communicate"}

data:{"content":" with"}

data:{"content":" human"}

data:{"content":" beings"}

data:{"content":" using"}

data:{"content":" natural"}

data:{"content":" language"}

data:{"content":" processing"}

data:{"content":"."}

data:[DONE]
Attention: the end must be 'data:[DONE]'
data:[DONE]

1.7 Curl Test#

Write to the end#

chatapi other required parameters can be customized, FaceTo-AI does not participate in the transmission, we will only send the relevant chat records to chatapi.
openai api docs
// ChatCompletionRequest represents a request structure for chat completion API.
type ChatCompletionRequest struct {
	Model            string                  `json:"model"`
	Messages         []ChatCompletionMessage `json:"messages"`
	MaxTokens        int                     `json:"max_tokens,omitempty"`
	Temperature      float32                 `json:"temperature,omitempty"`
	TopP             float32                 `json:"top_p,omitempty"`
	N                int                     `json:"n,omitempty"`
	Stream           bool                    `json:"stream,omitempty"`
	Stop             []string                `json:"stop,omitempty"`
	PresencePenalty  float32                 `json:"presence_penalty,omitempty"`
	FrequencyPenalty float32                 `json:"frequency_penalty,omitempty"`
	LogitBias        map[string]int          `json:"logit_bias,omitempty"`
	User             string                  `json:"user,omitempty"`
}
Modified at 2023-06-07 06:21:55
Previous
Security
Next
Get FaceTo-AI Room Link
Built with