API Reference
Completions
Authorization
Authorization
RequiredBearer <token>API Key
In: header
Request Body
application/json
Requiredmessages
RequiredMessagesmodel
RequiredModelfrequency_penalty
Frequency PenaltyDefault:
0
max_tokens
Max Tokensn
NDefault:
1
temperature
TemperatureDefault:
1
top_p
Top PDefault:
1
tools
Toolstool_choice
Tool Choicestream
StreamDefault:
false
moderate_before
ModerateBeforeResponse Body
Successful Response
response
RequiredResponse Completions Chat Completion Postexport type ResponseCompletionsChatCompletionPost = CreateChatCompletionResponse | CreateChatCompletionStreamResponse;
export type Id = string;
export type FinishReason = "stop" | "length" | "content_filter" | "tool_calls";
export type Index = number;
export type Content = string | null;
export type Role = "assistant";
export type ToolCalls = ToolCall[] | null;
export type Id1 = string;
export type Arguments = string;
export type Name = string;
export type Type = "function";
export type Logprobs = string | null;
export type Choices = ChatCompletionChoice[];
export type Created = number;
export type Model = string;
export type Object = "chat.completion";
export type SystemFingerprint = string | null;
export type CompletionTokens = number;
export type PromptTokens = number;
export type TotalTokens = number;
export type Id2 = string;
export type FinishReason1 = ("stop" | "length" | "content_filter" | "tool_calls") | null;
export type Index1 = number;
export type Content1 = string | null;
export type Role1 = ("system" | "user" | "assistant" | "tool") | null;
export type ToolCalls1 = ToolCallDelta[] | null;
export type Index2 = number;
export type Id3 = string;
export type Type1 = "function";
export type Name1 = string | null;
export type Arguments1 = string | null;
export type Choices1 = ChatCompletionChunkChoice[];
export type Created1 = number;
export type Model1 = string;
export type Object1 = "chat.completion.chunk";
export type SystemFingerprint1 = string | null;
/**
* Based on OpenAI's official Completion type
*/
export interface CreateChatCompletionResponse {
id: Id;
choices: Choices;
created: Created;
model: Model;
object: Object;
system_fingerprint?: SystemFingerprint;
usage?: CompletionUsage | null;
}
export interface ChatCompletionChoice {
finish_reason: FinishReason;
index: Index;
message: ChatCompletionResponseMessage;
logprobs?: Logprobs;
}
export interface ChatCompletionResponseMessage {
content?: Content;
role: Role;
tool_calls?: ToolCalls;
}
export interface ToolCall {
id: Id1;
function: ToolCallFunction;
type: Type;
}
export interface ToolCallFunction {
arguments: Arguments;
name: Name;
}
export interface CompletionUsage {
completion_tokens: CompletionTokens;
prompt_tokens: PromptTokens;
total_tokens: TotalTokens;
}
export interface CreateChatCompletionStreamResponse {
id: Id2;
choices: Choices1;
created: Created1;
model: Model1;
object: Object1;
system_fingerprint?: SystemFingerprint1;
}
export interface ChatCompletionChunkChoice {
finish_reason?: FinishReason1;
index: Index1;
delta: ChatCompletionDelta;
}
export interface ChatCompletionDelta {
content?: Content1;
role?: Role1;
tool_calls?: ToolCalls1;
}
export interface ToolCallDelta {
index: Index2;
id?: Id3;
type?: Type1;
function?: ToolCallFunctionDelta | null;
}
export interface ToolCallFunctionDelta {
name?: Name1;
arguments?: Arguments1;
}
curl -X POST "https://api.grayswan.ai/chat/completions" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "I need you to help me with something."
}
],
"model": "cygnet",
"stream": false
}'
{
"id": "string",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "string",
"role": "assistant",
"tool_calls": [
{
"id": "string",
"function": {
"arguments": "string",
"name": "string"
},
"type": "function"
}
]
},
"logprobs": "string"
}
],
"created": 0,
"model": "string",
"object": "chat.completion",
"system_fingerprint": "string",
"usage": {
"completion_tokens": 0,
"prompt_tokens": 0,
"total_tokens": 0
}
}