/** * This file was auto-generated by Fern from our API Definition. */ import * as environments from "./environments"; import * as core from "./core"; import * as Cohere from "./api/index"; import { V2 } from "./api/resources/v2/client/Client"; import { EmbedJobs } from "./api/resources/embedJobs/client/Client"; import { Datasets } from "./api/resources/datasets/client/Client"; import { Connectors } from "./api/resources/connectors/client/Client"; import { Models } from "./api/resources/models/client/Client"; import { Finetuning } from "./api/resources/finetuning/client/Client"; export declare namespace CohereClient { interface Options { environment?: core.Supplier; token?: core.Supplier; /** Override the X-Client-Name header */ clientName?: core.Supplier; fetcher?: core.FetchFunction; } interface RequestOptions { /** The maximum time to wait for a response in seconds. */ timeoutInSeconds?: number; /** The number of times to retry the request. Defaults to 2. */ maxRetries?: number; /** A hook to abort the request. */ abortSignal?: AbortSignal; /** Override the X-Client-Name header */ clientName?: string | undefined; /** Additional headers to include in the request. */ headers?: Record; } } export declare class CohereClient { protected readonly _options: CohereClient.Options; protected _v2: V2 | undefined; protected _embedJobs: EmbedJobs | undefined; protected _datasets: Datasets | undefined; protected _connectors: Connectors | undefined; protected _models: Models | undefined; protected _finetuning: Finetuning | undefined; constructor(_options?: CohereClient.Options); get v2(): V2; get embedJobs(): EmbedJobs; get datasets(): Datasets; get connectors(): Connectors; get models(): Models; get finetuning(): Finetuning; /** * Generates a streamed text response to a user message. * * To learn how to use the Chat API and RAG follow our [Text Generation guides](https://docs.cohere.com/docs/chat-api). */ chatStream(request: Cohere.ChatStreamRequest, requestOptions?: CohereClient.RequestOptions): Promise>; /** * Generates a text response to a user message. * To learn how to use the Chat API and RAG follow our [Text Generation guides](https://docs.cohere.com/docs/chat-api). * * @param {Cohere.ChatRequest} request * @param {CohereClient.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Cohere.BadRequestError} * @throws {@link Cohere.UnauthorizedError} * @throws {@link Cohere.ForbiddenError} * @throws {@link Cohere.NotFoundError} * @throws {@link Cohere.UnprocessableEntityError} * @throws {@link Cohere.TooManyRequestsError} * @throws {@link Cohere.InvalidTokenError} * @throws {@link Cohere.ClientClosedRequestError} * @throws {@link Cohere.InternalServerError} * @throws {@link Cohere.NotImplementedError} * @throws {@link Cohere.ServiceUnavailableError} * @throws {@link Cohere.GatewayTimeoutError} * * @example * await client.chat({ * message: "Can you give me a global market overview of solar panels?", * chatHistory: [{ * role: "TOOL" * }, { * role: "TOOL" * }], * promptTruncation: "OFF", * temperature: 0.3 * }) */ chat(request: Cohere.ChatRequest, requestOptions?: CohereClient.RequestOptions): Promise; /** * * This API is marked as "Legacy" and is no longer maintained. Follow the [migration guide](https://docs.cohere.com/docs/migrating-from-cogenerate-to-cochat) to start using the Chat with Streaming API. * * Generates realistic text conditioned on a given input. */ generateStream(request: Cohere.GenerateStreamRequest, requestOptions?: CohereClient.RequestOptions): Promise>; /** * * This API is marked as "Legacy" and is no longer maintained. Follow the [migration guide](https://docs.cohere.com/docs/migrating-from-cogenerate-to-cochat) to start using the Chat API. * * Generates realistic text conditioned on a given input. * * @param {Cohere.GenerateRequest} request * @param {CohereClient.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Cohere.BadRequestError} * @throws {@link Cohere.UnauthorizedError} * @throws {@link Cohere.ForbiddenError} * @throws {@link Cohere.NotFoundError} * @throws {@link Cohere.UnprocessableEntityError} * @throws {@link Cohere.TooManyRequestsError} * @throws {@link Cohere.InvalidTokenError} * @throws {@link Cohere.ClientClosedRequestError} * @throws {@link Cohere.InternalServerError} * @throws {@link Cohere.NotImplementedError} * @throws {@link Cohere.ServiceUnavailableError} * @throws {@link Cohere.GatewayTimeoutError} * * @example * await client.generate({ * prompt: "Please explain to me how LLMs work" * }) */ generate(request: Cohere.GenerateRequest, requestOptions?: CohereClient.RequestOptions): Promise; /** * This endpoint returns text and image embeddings. An embedding is a list of floating point numbers that captures semantic information about the content that it represents. * * Embeddings can be used to create classifiers as well as empower semantic search. To learn more about embeddings, see the embedding page. * * If you want to learn more how to use the embedding model, have a look at the [Semantic Search Guide](https://docs.cohere.com/docs/semantic-search). * * @param {Cohere.EmbedRequest} request * @param {CohereClient.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Cohere.BadRequestError} * @throws {@link Cohere.UnauthorizedError} * @throws {@link Cohere.ForbiddenError} * @throws {@link Cohere.NotFoundError} * @throws {@link Cohere.UnprocessableEntityError} * @throws {@link Cohere.TooManyRequestsError} * @throws {@link Cohere.InvalidTokenError} * @throws {@link Cohere.ClientClosedRequestError} * @throws {@link Cohere.InternalServerError} * @throws {@link Cohere.NotImplementedError} * @throws {@link Cohere.ServiceUnavailableError} * @throws {@link Cohere.GatewayTimeoutError} * * @example * await client.embed() */ embed(request?: Cohere.EmbedRequest, requestOptions?: CohereClient.RequestOptions): Promise; /** * This endpoint takes in a query and a list of texts and produces an ordered array with each text assigned a relevance score. * * @param {Cohere.RerankRequest} request * @param {CohereClient.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Cohere.BadRequestError} * @throws {@link Cohere.UnauthorizedError} * @throws {@link Cohere.ForbiddenError} * @throws {@link Cohere.NotFoundError} * @throws {@link Cohere.UnprocessableEntityError} * @throws {@link Cohere.TooManyRequestsError} * @throws {@link Cohere.InvalidTokenError} * @throws {@link Cohere.ClientClosedRequestError} * @throws {@link Cohere.InternalServerError} * @throws {@link Cohere.NotImplementedError} * @throws {@link Cohere.ServiceUnavailableError} * @throws {@link Cohere.GatewayTimeoutError} * * @example * await client.rerank({ * query: "query", * documents: ["documents"] * }) */ rerank(request: Cohere.RerankRequest, requestOptions?: CohereClient.RequestOptions): Promise; /** * This endpoint makes a prediction about which label fits the specified text inputs best. To make a prediction, Classify uses the provided `examples` of text + label pairs as a reference. * Note: [Fine-tuned models](https://docs.cohere.com/docs/classify-fine-tuning) trained on classification examples don't require the `examples` parameter to be passed in explicitly. * * @param {Cohere.ClassifyRequest} request * @param {CohereClient.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Cohere.BadRequestError} * @throws {@link Cohere.UnauthorizedError} * @throws {@link Cohere.ForbiddenError} * @throws {@link Cohere.NotFoundError} * @throws {@link Cohere.UnprocessableEntityError} * @throws {@link Cohere.TooManyRequestsError} * @throws {@link Cohere.InvalidTokenError} * @throws {@link Cohere.ClientClosedRequestError} * @throws {@link Cohere.InternalServerError} * @throws {@link Cohere.NotImplementedError} * @throws {@link Cohere.ServiceUnavailableError} * @throws {@link Cohere.GatewayTimeoutError} * * @example * await client.classify({ * inputs: ["inputs"] * }) */ classify(request: Cohere.ClassifyRequest, requestOptions?: CohereClient.RequestOptions): Promise; /** * * This API is marked as "Legacy" and is no longer maintained. Follow the [migration guide](https://docs.cohere.com/docs/migrating-from-cogenerate-to-cochat) to start using the Chat API. * * Generates a summary in English for a given text. * * @param {Cohere.SummarizeRequest} request * @param {CohereClient.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Cohere.BadRequestError} * @throws {@link Cohere.UnauthorizedError} * @throws {@link Cohere.ForbiddenError} * @throws {@link Cohere.NotFoundError} * @throws {@link Cohere.UnprocessableEntityError} * @throws {@link Cohere.TooManyRequestsError} * @throws {@link Cohere.InvalidTokenError} * @throws {@link Cohere.ClientClosedRequestError} * @throws {@link Cohere.InternalServerError} * @throws {@link Cohere.NotImplementedError} * @throws {@link Cohere.ServiceUnavailableError} * @throws {@link Cohere.GatewayTimeoutError} * * @example * await client.summarize({ * text: "text" * }) */ summarize(request: Cohere.SummarizeRequest, requestOptions?: CohereClient.RequestOptions): Promise; /** * This endpoint splits input text into smaller units called tokens using byte-pair encoding (BPE). To learn more about tokenization and byte pair encoding, see the tokens page. * * @param {Cohere.TokenizeRequest} request * @param {CohereClient.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Cohere.BadRequestError} * @throws {@link Cohere.UnauthorizedError} * @throws {@link Cohere.ForbiddenError} * @throws {@link Cohere.NotFoundError} * @throws {@link Cohere.UnprocessableEntityError} * @throws {@link Cohere.TooManyRequestsError} * @throws {@link Cohere.InvalidTokenError} * @throws {@link Cohere.ClientClosedRequestError} * @throws {@link Cohere.InternalServerError} * @throws {@link Cohere.NotImplementedError} * @throws {@link Cohere.ServiceUnavailableError} * @throws {@link Cohere.GatewayTimeoutError} * * @example * await client.tokenize({ * text: "tokenize me! :D", * model: "command" * }) */ tokenize(request: Cohere.TokenizeRequest, requestOptions?: CohereClient.RequestOptions): Promise; /** * This endpoint takes tokens using byte-pair encoding and returns their text representation. To learn more about tokenization and byte pair encoding, see the tokens page. * * @param {Cohere.DetokenizeRequest} request * @param {CohereClient.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Cohere.BadRequestError} * @throws {@link Cohere.UnauthorizedError} * @throws {@link Cohere.ForbiddenError} * @throws {@link Cohere.NotFoundError} * @throws {@link Cohere.UnprocessableEntityError} * @throws {@link Cohere.TooManyRequestsError} * @throws {@link Cohere.InvalidTokenError} * @throws {@link Cohere.ClientClosedRequestError} * @throws {@link Cohere.InternalServerError} * @throws {@link Cohere.NotImplementedError} * @throws {@link Cohere.ServiceUnavailableError} * @throws {@link Cohere.GatewayTimeoutError} * * @example * await client.detokenize({ * tokens: [1], * model: "model" * }) */ detokenize(request: Cohere.DetokenizeRequest, requestOptions?: CohereClient.RequestOptions): Promise; /** * Checks that the api key in the Authorization header is valid and active * * @param {CohereClient.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Cohere.BadRequestError} * @throws {@link Cohere.UnauthorizedError} * @throws {@link Cohere.ForbiddenError} * @throws {@link Cohere.NotFoundError} * @throws {@link Cohere.UnprocessableEntityError} * @throws {@link Cohere.TooManyRequestsError} * @throws {@link Cohere.InvalidTokenError} * @throws {@link Cohere.ClientClosedRequestError} * @throws {@link Cohere.InternalServerError} * @throws {@link Cohere.NotImplementedError} * @throws {@link Cohere.ServiceUnavailableError} * @throws {@link Cohere.GatewayTimeoutError} * * @example * await client.checkApiKey() */ checkApiKey(requestOptions?: CohereClient.RequestOptions): Promise; protected _getAuthorizationHeader(): Promise; }