转发copilot chat 接口
POST
/自定义后缀/v1/chat/completions
请求参数
Header 参数
Authorization
string
可选
示例值:
Bearer ghu-XXX
Body 参数text/plain
示例
示例值:{
"stream":true,
"model":"gpt-4",
"messages": [{"role": "user", "content": "你好"}]
}
示例代码
Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST '/自定义后缀/v1/chat/completions' \
--header 'Authorization: Bearer ghu-XXX' \
--header 'Content-Type: text/plain' \
--data-raw '{
"stream":true,
"model":"gpt-4",
"messages": [{"role": "user", "content": "你好"}]
}'
返回响应
🟢200成功
application/json
Body
object {0}
示例
data: {
"choices": [
{
"index": 0,
"delta": {
"content": null,
"role": "assistant"
}
}
],
"created": 1703682082,
"id": "chatcmpl-8aNpCyVK7wPuBdxsIYXiFGrpwEsNm"
}
data: {
"choices": [
{
"index": 0,
"delta": {
"content": "你",
"role": null
}
}
],
"created": 1703682082,
"id": "chatcmpl-8aNpCyVK7wPuBdxsIYXiFGrpwEsNm"
}
data: {
"choices": [
{
"index": 0,
"delta": {
"content": "好",
"role": null
}
}
],
"created": 1703682082,
"id": "chatcmpl-8aNpCyVK7wPuBdxsIYXiFGrpwEsNm"
}
data: {
"choices": [
{
"index": 0,
"delta": {
"content": "!",
"role": null
}
}
],
"created": 1703682082,
"id": "chatcmpl-8aNpCyVK7wPuBdxsIYXiFGrpwEsNm"
}
data: {
"choices": [
{
"index": 0,
"delta": {
"content": "有",
"role": null
}
}
],
"created": 1703682082,
"id": "chatcmpl-8aNpCyVK7wPuBdxsIYXiFGrpwEsNm"
}
data: {
"choices": [
{
"index": 0,
"delta": {
"content": "什",
"role": null
}
}
],
"created": 1703682082,
"id": "chatcmpl-8aNpCyVK7wPuBdxsIYXiFGrpwEsNm"
}
data: {
"choices": [
{
"index": 0,
"delta": {
"content": "么",
"role": null
}
}
],
"created": 1703682082,
"id": "chatcmpl-8aNpCyVK7wPuBdxsIYXiFGrpwEsNm"
}
data: {
"choices": [
{
"index": 0,
"delta": {
"content": "我",
"role": null
}
}
],
"created": 1703682082,
"id": "chatcmpl-8aNpCyVK7wPuBdxsIYXiFGrpwEsNm"
}
data: {
"choices": [
{
"index": 0,
"delta": {
"content": "可以",
"role": null
}
}
],
"created": 1703682082,
"id": "chatcmpl-8aNpCyVK7wPuBdxsIYXiFGrpwEsNm"
}
data: {
"choices": [
{
"index": 0,
"delta": {
"content": "帮",
"role": null
}
}
],
"created": 1703682082,
"id": "chatcmpl-8aNpCyVK7wPuBdxsIYXiFGrpwEsNm"
}
data: {
"choices": [
{
"index": 0,
"delta": {
"content": "助",
"role": null
}
}
],
"created": 1703682082,
"id": "chatcmpl-8aNpCyVK7wPuBdxsIYXiFGrpwEsNm"
}
data: {
"choices": [
{
"index": 0,
"delta": {
"content": "你",
"role": null
}
}
],
"created": 1703682082,
"id": "chatcmpl-8aNpCyVK7wPuBdxsIYXiFGrpwEsNm"
}
data: {
"choices": [
{
"index": 0,
"delta": {
"content": "的",
"role": null
}
}
],
"created": 1703682082,
"id": "chatcmpl-8aNpCyVK7wPuBdxsIYXiFGrpwEsNm"
}
data: {
"choices": [
{
"index": 0,
"delta": {
"content": "吗",
"role": null
}
}
],
"created": 1703682082,
"id": "chatcmpl-8aNpCyVK7wPuBdxsIYXiFGrpwEsNm"
}
data: {
"choices": [
{
"index": 0,
"delta": {
"content": "?",
"role": null
}
}
],
"created": 1703682082,
"id": "chatcmpl-8aNpCyVK7wPuBdxsIYXiFGrpwEsNm"
}
data: {
"choices": [
{
"finish_reason": "stop",
"index": 0,
"delta": {
"content": null,
"role": null
}
}
],
"created": 1703682082,
"id": "chatcmpl-8aNpCyVK7wPuBdxsIYXiFGrpwEsNm"
}
data: [DONE
]
修改于 2024-04-12 17:20:50