OpenAI API

Below are the official API interfaces supported by us, which are no different from the official interfaces open in new window .

TIP

All your_api_key on this page represent your obtained api_key. Please replace it with your real api_key when actually making requests.

Authentication Method

Change the original api_key starting with sk- to our platform-specific api_key starting with sb-.

Authorization: Bearer your_api_key

Chat

  • POST Request Address: https://api.openai-365.com/v1/chat/completions

For example, if you want to call the gpt-4 model, set the model in the request json to gpt-4.

Currently, the chat interface supports models such as gpt-4 and gpt-3.5-turbo.

gpt-4-32k is not supported.

If you don't know what you're doing, it's not recommended to use gpt-4-0314 or gpt-3.5-turbo-0301.

  • Request header example:
{
"Authorization": "Bearer your_api_key",
"Content-Type": "application/json"
}
  • Request body example in JSON format:
{
  "model": "gpt-3.5-turbo",
  "messages": [
    {
      "role": "user",
      "content": "There are 9 birds on a tree. A hunter shoots and kills one of them. How many birds are left on the tree?"
    }
  ]
}
  • Code example:
const fetch = require("node-fetch");

fetch("https://api.openai-365.com/v1/chat/completions", {
  method: "POST",
  headers: {
    Authorization: "Bearer Your api_key",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "gpt-3.5-turbo",
    stream: false,
    messages: [{ role: "user", content: "There were 9 birds on a tree. A hunter shot and killed 1 bird. How many birds are still on the tree?" }],
  }),
});
import requests

headers = {
    'Authorization': 'Bearer Your api_key',
    'Content-Type': 'application/json',
}

data = '{ "model": "gpt-3.5-turbo", "stream": false, "messages": [ { "role": "user", "content": "\u4F60\u597D" } ] }'

response = requests.post('https://api.openai-365.com/v1/chat/completions', headers=headers, data=data)
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://api.openai-365.com/v1/chat/completions');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\r\n    \"model\": \"gpt-3.5-turbo\",\r\n    \"stream\": false,\r\n    \"messages\": [\r\n        {\r\n            \"role\": \"user\",\r\n            \"content\": \"Hello\"\r\n        }\r\n    ]\r\n}");

$headers = array();
$headers[] = 'Authorization: Bearer Your api_key';
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close($ch);

Text Completion

  • Request URL: POST https://api.openai-365.com/v1/completions

  • Code Example:

const fetch = require("node-fetch");

fetch("https://api.openai-365.com/v1/completions", {
  method: "POST",
  headers: {
    Authorization: "Bearer Your api_key",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "text-davinci-003",
    prompt: "Say this is a test",
    max_tokens: 7,
    temperature: 0,
    top_p: 1,
    n: 1,
    stream: false,
    logprobs: null,
    stop: "\n",
  }),
});
import requests

headers = {
    'Authorization': 'Bearer Your api_key',
    'Content-Type': 'application/json',
}

data = '{ "model": "text-davinci-003", "prompt": "Say this is a test", "max_tokens": 7, "temperature": 0, "top_p": 1, "n": 1, "stream": false, "logprobs": null, "stop": "\\n" }'

response = requests.post('https://api.openai-365.com/v1/completions', headers=headers, data=data)
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://api.openai-365.com/v1/completions');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\r\n    \"model\": \"text-davinci-003\",\r\n    \"prompt\": \"Say this is a test\",\r\n    \"max_tokens\": 7,\r\n    \"temperature\": 0,\r\n    \"top_p\": 1,\r\n    \"n\": 1,\r\n    \"stream\": false,\r\n    \"logprobs\": null,\r\n    \"stop\": \"n\"\r\n}");

$headers = array();
$headers[] = 'Authorization: Bearer Your api_key';
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close($ch);

Moderation

  • Request URL: POST https://api.openai-365.com/v1/moderations

  • Code Example:

const fetch = require("node-fetch");

fetch("https://api.openai-365.com/v1/moderations", {
  method: "POST",
  headers: {
    Authorization: "Bearer Your api_key",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ input: "I want to kill them." }),
});
import requests

headers = {
    'Authorization': 'Bearer Your api_key',
    'Content-Type': 'application/json',
}

data = '{ "input": "I want to kill them." }'

response = requests.post('https://api.openai-365.com/v1/moderations', headers=headers, data=data)
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://api.openai-365.com/v1/moderations');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\r\n    \"input\": \"I want to kill them.\"\r\n}");

$headers = array();
$headers[] = 'Authorization: Bearer Your api_key';
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close($ch);

Embeddings

  • Request URL: POST https://api.openai-365.com/v1/embeddings

  • Code Example:

const fetch = require("node-fetch");

fetch("https://api.openai-365.com/v1/embeddings", {
  method: "POST",
  headers: {
    Authorization: "Bearer Your api_key",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    input: "The food was delicious and the waiter...",
    model: "text-embedding-ada-002",
  }),
});

More APIs are under development...