import { APIResource } from "../../resource.js"; import * as Core from "../../core.js"; import { Stream } from "../../streaming.js"; export declare class Completions extends APIResource { /** * Chat * * @example * ```ts * const chatCompletion = await client.chat.completions.create( * { model: 'model' }, * ); * ``` */ create(params: ChatCompletionCreateParamsNonStreaming, options?: Core.RequestOptions): Core.APIPromise; create(params: ChatCompletionCreateParamsStreaming, options?: Core.RequestOptions): Core.APIPromise>; create(params: ChatCompletionCreateParamsBase, options?: Core.RequestOptions): Core.APIPromise | ChatCompletion>; } export type ChatCompletion = ChatCompletion.ChatCompletionResponse | ChatCompletion.ChatChunkResponse | ChatCompletion.ErrorChunkResponse; export declare namespace ChatCompletion { interface ChatCompletionResponse { id: string; choices: Array; created: number; model: string; object: 'chat.completion'; system_fingerprint: string; time_info: ChatCompletionResponse.TimeInfo; usage: ChatCompletionResponse.Usage; service_tier?: string | null; [k: string]: unknown; } namespace ChatCompletionResponse { interface Choice { finish_reason: 'stop' | 'length' | 'content_filter' | 'tool_calls'; index: number; message: Choice.Message; logprobs?: Choice.Logprobs | null; reasoning_logprobs?: Choice.ReasoningLogprobs | null; [k: string]: unknown; } namespace Choice { interface Message { role: 'assistant' | 'user' | 'system' | 'tool'; content?: string | null; reasoning?: string | null; tool_calls?: Array | null; [k: string]: unknown; } namespace Message { /** * A tool call for an assistant. */ interface ToolCall { id: string; /** * A function call for an assistant tool. */ function: ToolCall.Function; type: 'function'; [k: string]: unknown; } namespace ToolCall { /** * A function call for an assistant tool. */ interface Function { arguments: string; name: string; [k: string]: unknown; } } } interface Logprobs { content: Array | null; refusal: Array | null; [k: string]: unknown; } namespace Logprobs { interface Content { token: string; logprob: number; top_logprobs: Array; bytes?: Array | null; [k: string]: unknown; } namespace Content { interface TopLogprob { token: string; logprob: number; bytes?: Array | null; [k: string]: unknown; } } interface Refusal { token: string; logprob: number; top_logprobs: Array; bytes?: Array | null; [k: string]: unknown; } namespace Refusal { interface TopLogprob { token: string; logprob: number; bytes?: Array | null; [k: string]: unknown; } } } interface ReasoningLogprobs { content: Array | null; refusal: Array | null; [k: string]: unknown; } namespace ReasoningLogprobs { interface Content { token: string; logprob: number; top_logprobs: Array; bytes?: Array | null; [k: string]: unknown; } namespace Content { interface TopLogprob { token: string; logprob: number; bytes?: Array | null; [k: string]: unknown; } } interface Refusal { token: string; logprob: number; top_logprobs: Array; bytes?: Array | null; [k: string]: unknown; } namespace Refusal { interface TopLogprob { token: string; logprob: number; bytes?: Array | null; [k: string]: unknown; } } } } interface TimeInfo { completion_time?: number; prompt_time?: number; queue_time?: number; total_time?: number; [k: string]: unknown; } interface Usage { completion_tokens?: number; completion_tokens_details?: Usage.CompletionTokensDetails | null; prompt_tokens?: number; prompt_tokens_details?: Usage.PromptTokensDetails | null; total_tokens?: number; [k: string]: unknown; } namespace Usage { interface CompletionTokensDetails { accepted_prediction_tokens?: number | null; rejected_prediction_tokens?: number | null; [k: string]: unknown; } interface PromptTokensDetails { cached_tokens?: number; [k: string]: unknown; } } } interface ChatChunkResponse { id: string; created: number; model: string; object: 'chat.completion.chunk' | 'text_completion'; system_fingerprint: string; choices?: Array | null; service_tier?: string | null; time_info?: ChatChunkResponse.TimeInfo | null; usage?: ChatChunkResponse.Usage | null; [k: string]: unknown; } namespace ChatChunkResponse { interface Choice { index: number; delta?: Choice.Delta | null; finish_reason?: 'stop' | 'length' | 'content_filter' | 'tool_calls' | null; logprobs?: Choice.Logprobs | null; reasoning_logprobs?: Choice.ReasoningLogprobs | null; text?: string | null; tokens?: Array | null; [k: string]: unknown; } namespace Choice { interface Delta { content?: string | null; reasoning?: string | null; role?: 'assistant' | 'user' | 'system' | 'tool' | null; tokens?: Array | null; tool_calls?: Array | null; [k: string]: unknown; } namespace Delta { /** * Streaming only. Represents a function call in an assistant tool call. */ interface ToolCall { /** * Streaming only. Represents a function in an assistant tool call. */ function: ToolCall.Function; type: 'function'; id?: string | null; index?: number | null; [k: string]: unknown; } namespace ToolCall { /** * Streaming only. Represents a function in an assistant tool call. */ interface Function { arguments?: string | null; name?: string | null; [k: string]: unknown; } } } interface Logprobs { content: Array | null; refusal: Array | null; [k: string]: unknown; } namespace Logprobs { interface Content { token: string; logprob: number; top_logprobs: Array; bytes?: Array | null; [k: string]: unknown; } namespace Content { interface TopLogprob { token: string; logprob: number; bytes?: Array | null; [k: string]: unknown; } } interface Refusal { token: string; logprob: number; top_logprobs: Array; bytes?: Array | null; [k: string]: unknown; } namespace Refusal { interface TopLogprob { token: string; logprob: number; bytes?: Array | null; [k: string]: unknown; } } } interface ReasoningLogprobs { content: Array | null; refusal: Array | null; [k: string]: unknown; } namespace ReasoningLogprobs { interface Content { token: string; logprob: number; top_logprobs: Array; bytes?: Array | null; [k: string]: unknown; } namespace Content { interface TopLogprob { token: string; logprob: number; bytes?: Array | null; [k: string]: unknown; } } interface Refusal { token: string; logprob: number; top_logprobs: Array; bytes?: Array | null; [k: string]: unknown; } namespace Refusal { interface TopLogprob { token: string; logprob: number; bytes?: Array | null; [k: string]: unknown; } } } } interface TimeInfo { completion_time?: number; prompt_time?: number; queue_time?: number; total_time?: number; [k: string]: unknown; } interface Usage { completion_tokens?: number; completion_tokens_details?: Usage.CompletionTokensDetails | null; prompt_tokens?: number; prompt_tokens_details?: Usage.PromptTokensDetails | null; total_tokens?: number; [k: string]: unknown; } namespace Usage { interface CompletionTokensDetails { accepted_prediction_tokens?: number | null; rejected_prediction_tokens?: number | null; [k: string]: unknown; } interface PromptTokensDetails { cached_tokens?: number; [k: string]: unknown; } } } interface ErrorChunkResponse { error: ErrorChunkResponse.Error; status_code: number; [k: string]: unknown; } namespace ErrorChunkResponse { interface Error { id?: string | null; code?: string | null; message?: string | null; param?: string | null; type?: string | null; [k: string]: unknown; } } } export type ChatCompletionCreateParams = ChatCompletionCreateParamsNonStreaming | ChatCompletionCreateParamsStreaming; export interface ChatCompletionCreateParamsNonStreaming extends ChatCompletionCreateParamsBase { stream?: false | null; } export interface ChatCompletionCreateParamsStreaming extends ChatCompletionCreateParamsBase { stream: true; } export interface ChatCompletionCreateParamsBase { /** * Body param: */ model: string; /** * Body param: When True, removes reasoning content from messages that appear * before the latest user message. */ clear_thinking?: boolean | null; /** * Body param: Disables reasoning for reasoning models. If set to True, the model * will not use any reasoning in its response. */ disable_reasoning?: boolean | null; /** * Body param: Number between -2.0 and 2.0. Positive values penalize new tokens * based on their existing frequency in the text so far, decreasing the model's * likelihood to repeat the same line verbatim. */ frequency_penalty?: number | null; /** * Body param: Modify the likelihood of specified tokens appearing in the * completion. * * Accepts a JSON object that maps tokens (specified by their token ID in the * tokenizer) to an associated bias value from -100 to 100. Mathematically, the * bias is added to the logits generated by the model prior to sampling. The exact * effect will vary per model, but values between -1 and 1 should decrease or * increase likelihood of selection; values like -100 or 100 should result in a ban * or exclusive selection of the relevant token. */ logit_bias?: { [key: string]: number; } | null; /** * Body param: Whether to return log probabilities of the output tokens or not. If * true, returns the log probabilities of each output token returned in the content * of message. */ logprobs?: boolean | null; /** * Body param: An upper bound for the number of tokens that can be generated for a * completion, including visible output tokens and reasoning tokens. */ max_completion_tokens?: number | null; /** * Body param: The maximum number of tokens that can be generated in the chat * completion. The total length of input tokens and generated tokens is limited by * the model's context length. This value is now deprecated in favor of * max_completion_tokens. */ max_tokens?: number | null; /** * Body param: */ messages?: Array | null; /** * Body param: The minimum number of tokens to generate for a completion. If not * specified or set to 0, the model will generate as many tokens as it deems * necessary. Setting to -1 sets to max sequence length. */ min_completion_tokens?: number | null; /** * Body param: The minimum number of tokens to generate for a completion. If not * specified or set to 0, the model will generate as many tokens as it deems * necessary. Setting to -1 sets to max sequence length. */ min_tokens?: number | null; /** * Body param: How many chat completion choices to generate for each input message. * Note that you will be charged based on the number of generated tokens across all * of the choices. Keep n as 1 to minimize costs. */ n?: number | null; /** * Body param: */ parallel_tool_calls?: boolean | null; /** * Body param: Configuration for a Predicted Output, which can greatly improve * response times when large parts of the model response are known ahead of time. * This is most common when regenerating a file with only minor changes to most of * the content. */ prediction?: ChatCompletionCreateParams.Prediction | null; /** * Body param: Number between -2.0 and 2.0. Positive values penalize new tokens * based on whether they appear in the text so far, increasing the model's * likelihood to talk about new topics. */ presence_penalty?: number | null; /** * Body param: Constrains effort on reasoning for reasoning models. Currently * supported values are low, medium, and high. Reducing reasoning effort can result * in faster responses and fewer tokens used on reasoning in a response. If set to * None, the model will use the default reasoning effort for the model. */ reasoning_effort?: 'low' | 'medium' | 'high' | null; /** * Body param: Determines how reasoning is returned in the response. If set to * `parsed`, the reasoning will be returned in the `reasoning` field of the * response message as a string. If set to `raw`, the reasoning will be returned in * the `content` field of the response message with special tokens. If set to * `hidden`, the reasoning will not be returned in the response. If set to `none`, * the model's default behavior will be used. If set to `text_parsed`, the * reasoning will be returned in the `reasoning` field of the response message as a * string, similar to `parsed`, but logprobs will not be separated into * `reasoning_logprobs` and `logprobs`. */ reasoning_format?: 'none' | 'parsed' | 'text_parsed' | 'raw' | 'hidden'; /** * Body param: A response format for text. */ response_format?: ChatCompletionCreateParams.ResponseFormatText | ChatCompletionCreateParams.ResponseFormatJsonObject | ChatCompletionCreateParams.ResponseFormatJsonSchema | null; /** * Body param: If specified, our system will make a best effort to sample * deterministically, such that repeated requests with the same `seed` and * parameters should return the same result. Determinism is not guaranteed. */ seed?: number | null; /** * Body param: */ service_tier?: 'auto' | 'default' | 'flex' | 'priority' | null; /** * Body param: Up to 4 sequences where the API will stop generating further tokens. * The returned text will not contain the stop sequence. */ stop?: string | Array | null; /** * Body param: */ stream?: boolean | null; /** * Body param: Options for streaming. */ stream_options?: ChatCompletionCreateParams.StreamOptions | null; /** * Body param: What sampling temperature to use, between 0 and 1.5. Higher values * like 0.8 will make the output more random, while lower values like 0.2 will make * it more focused and deterministic. We generally recommend altering this or * `top_p` but not both. */ temperature?: number | null; /** * Body param: A choice object. */ tool_choice?: 'none' | 'auto' | 'required' | ChatCompletionCreateParams.ChoiceObject | null; /** * Body param: */ tools?: Array | null; /** * Body param: An integer between 0 and 20 specifying the number of most likely * tokens to return at each token position, each with an associated log * probability. logprobs must be set to true if this parameter is used. */ top_logprobs?: number | null; /** * Body param: An alternative to sampling with temperature, called nucleus * sampling, where the model considers the results of the tokens with top_p * probability mass. So 0.1 means only the tokens comprising the top 10% * probability mass are considered. We generally recommend altering this or * `temperature` but not both. */ top_p?: number | null; /** * Body param: A unique identifier representing your end-user, which can help * Cerebras to monitor and detect abuse. */ user?: string | null; /** * Header param: */ 'CF-RAY'?: string; /** * Header param: */ 'X-Amz-Cf-Id'?: string; /** * Header param: */ 'X-delay-time'?: number; } export declare namespace ChatCompletionCreateParams { /** * A message request from the system. */ interface SystemMessageRequest { content: string | Array; name?: string | null; role?: 'system'; [k: string]: unknown; } namespace SystemMessageRequest { /** * Text content for a message. */ interface TextContent { text: string; type: 'text'; [k: string]: unknown; } /** * Image URL content for a message. */ interface ImageURLContent { /** * Image URL */ image_url: ImageURLContent.ImageURL; type: 'image_url'; [k: string]: unknown; } namespace ImageURLContent { /** * Image URL */ interface ImageURL { url: string; detail?: string | null; [k: string]: unknown; } } /** * Image URL content for a message. */ interface ImageContent { image: string; type: 'image'; [k: string]: unknown; } } /** * A message request from the user. */ interface UserMessageRequest { content: string | Array; name?: string | null; role?: 'user'; [k: string]: unknown; } namespace UserMessageRequest { /** * Text content for a message. */ interface TextContent { text: string; type: 'text'; [k: string]: unknown; } /** * Image URL content for a message. */ interface ImageURLContent { /** * Image URL */ image_url: ImageURLContent.ImageURL; type: 'image_url'; [k: string]: unknown; } namespace ImageURLContent { /** * Image URL */ interface ImageURL { url: string; detail?: string | null; [k: string]: unknown; } } /** * Image URL content for a message. */ interface ImageContent { image: string; type: 'image'; [k: string]: unknown; } } /** * A message request from an assistant. */ interface AssistantMessageRequest { content?: string | Array | null; name?: string | null; reasoning?: string | Array | null; role?: 'assistant'; tool_calls?: Array | null; [k: string]: unknown; } namespace AssistantMessageRequest { /** * Text content for a message. */ interface UnionMember1 { text: string; type: 'text'; [k: string]: unknown; } /** * A tool call for an assistant. */ interface ToolCall { id: string; /** * A function call for an assistant tool. */ function: ToolCall.Function; type: 'function'; [k: string]: unknown; } namespace ToolCall { /** * A function call for an assistant tool. */ interface Function { arguments: string; name: string; [k: string]: unknown; } } } /** * A message request from a tool. */ interface ToolMessageRequest { content: string | Array; tool_call_id: string; name?: string | null; role?: 'tool'; [k: string]: unknown; } namespace ToolMessageRequest { /** * Text content for a message. */ interface UnionMember1 { text: string; type: 'text'; [k: string]: unknown; } } /** * Configuration for a Predicted Output, which can greatly improve response times * when large parts of the model response are known ahead of time. This is most * common when regenerating a file with only minor changes to most of the content. */ interface Prediction { content: string | Array; type: 'content'; [k: string]: unknown; } namespace Prediction { /** * Text content for a message. */ interface UnionMember1 { text: string; type: 'text'; [k: string]: unknown; } } /** * A response format for text. */ interface ResponseFormatText { type: 'text'; [k: string]: unknown; } /** * A response format for a JSON object. */ interface ResponseFormatJsonObject { type: 'json_object'; [k: string]: unknown; } /** * A response format for a JSON schema. */ interface ResponseFormatJsonSchema { /** * A JSON Schema object. */ json_schema: ResponseFormatJsonSchema.JsonSchema; type: 'json_schema'; [k: string]: unknown; } namespace ResponseFormatJsonSchema { /** * A JSON Schema object. */ interface JsonSchema { name: string; description?: string | null; schema?: unknown | null; strict?: boolean | null; [k: string]: unknown; } } /** * Options for streaming. */ interface StreamOptions { include_usage?: boolean | null; [k: string]: unknown; } /** * A choice object. */ interface ChoiceObject { /** * A function for a choice object. */ function: ChoiceObject.Function; type: string; [k: string]: unknown; } namespace ChoiceObject { /** * A function for a choice object. */ interface Function { name: string; [k: string]: unknown; } } /** * A tool object */ interface Tool { /** * A function object. */ function: Tool.Function; type: string; [k: string]: unknown; } namespace Tool { /** * A function object. */ interface Function { name: string; description?: string | null; /** * Represents the parameters a function accepts. This model is designed to be * flexible to accommodate any JSON Schema. The key-value pairs you provide will * define the parameters. */ parameters?: unknown | null; strict?: boolean; [k: string]: unknown; } } } /** * @deprecated Use ChatCompletionCreateParams instead */ export type CompletionCreateParams = ChatCompletionCreateParams; /** * @deprecated Use ChatCompletion instead */ export type CompletionCreateResponse = ChatCompletion; export declare namespace Completions { export { type CompletionCreateResponse as CompletionCreateResponse, type ChatCompletion as ChatCompletion, type CompletionCreateParams as CompletionCreateParams, type ChatCompletionCreateParams as ChatCompletionCreateParams, type ChatCompletionCreateParamsNonStreaming as ChatCompletionCreateParamsNonStreaming, type ChatCompletionCreateParamsStreaming as ChatCompletionCreateParamsStreaming, }; } //# sourceMappingURL=completions.d.ts.map