Skip to content

Latest commit

Β 

History

History
1832 lines (1264 loc) Β· 21.2 KB

reference.md

File metadata and controls

1832 lines (1264 loc) Β· 21.2 KB

Reference

client.checkApiKey() -> Cohere.CheckApiKeyResponse

πŸ“ Description

Checks that the api key in the Authorization header is valid and active

πŸ”Œ Usage

await client.checkApiKey();

βš™οΈ Parameters

requestOptions: CohereClient.RequestOptions

V2

client.v2.chatStream({ ...params }) -> core.Stream

πŸ“ Description

Generates a text response to a user message. To learn how to use the Chat API and RAG follow our Text Generation guides.

Follow the Migration Guide for instructions on moving from API v1 to API v2.

πŸ”Œ Usage

const response = await client.v2.chatStream({
    model: "model",
    messages: [
        {
            role: "tool",
            toolCallId: "messages",
            content: "messages",
        },
    ],
});
for await (const item of response) {
    console.log(item);
}

βš™οΈ Parameters

request: Cohere.V2ChatStreamRequest

requestOptions: V2.RequestOptions

client.v2.chat({ ...params }) -> Cohere.ChatResponse

πŸ“ Description

Generates a text response to a user message and streams it down, token by token. To learn how to use the Chat API with streaming follow our Text Generation guides.

Follow the Migration Guide for instructions on moving from API v1 to API v2.

πŸ”Œ Usage

await client.v2.chat({
    model: "model",
    messages: [
        {
            role: "tool",
            toolCallId: "messages",
            content: "messages",
        },
    ],
});

βš™οΈ Parameters

request: Cohere.V2ChatRequest

requestOptions: V2.RequestOptions

client.v2.embed({ ...params }) -> Cohere.EmbedByTypeResponse

πŸ“ Description

This endpoint returns text embeddings. An embedding is a list of floating point numbers that captures semantic information about the text that it represents.

Embeddings can be used to create text 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.

πŸ”Œ Usage

await client.v2.embed({
    model: "model",
    inputType: "search_document",
    embeddingTypes: ["float"],
});

βš™οΈ Parameters

request: Cohere.V2EmbedRequest

requestOptions: V2.RequestOptions

client.v2.rerank({ ...params }) -> Cohere.V2RerankResponse

πŸ“ Description

This endpoint takes in a query and a list of texts and produces an ordered array with each text assigned a relevance score.

πŸ”Œ Usage

await client.v2.rerank({
    model: "model",
    query: "query",
    documents: ["documents"],
});

βš™οΈ Parameters

request: Cohere.V2RerankRequest

requestOptions: V2.RequestOptions

EmbedJobs

client.embedJobs.list() -> Cohere.ListEmbedJobResponse

πŸ“ Description

The list embed job endpoint allows users to view all embed jobs history for that specific user.

πŸ”Œ Usage

await client.embedJobs.list();

βš™οΈ Parameters

requestOptions: EmbedJobs.RequestOptions

client.embedJobs.create({ ...params }) -> Cohere.CreateEmbedJobResponse

πŸ“ Description

This API launches an async Embed job for a Dataset of type embed-input. The result of a completed embed job is new Dataset of type embed-output, which contains the original text entries and the corresponding embeddings.

πŸ”Œ Usage

await client.embedJobs.create({
    model: "model",
    datasetId: "dataset_id",
    inputType: "search_document",
});

βš™οΈ Parameters

request: Cohere.CreateEmbedJobRequest

requestOptions: EmbedJobs.RequestOptions

client.embedJobs.get(id) -> Cohere.EmbedJob

πŸ“ Description

This API retrieves the details about an embed job started by the same user.

πŸ”Œ Usage

await client.embedJobs.get("id");

βš™οΈ Parameters

id: string β€” The ID of the embed job to retrieve.

requestOptions: EmbedJobs.RequestOptions

client.embedJobs.cancel(id) -> void

πŸ“ Description

This API allows users to cancel an active embed job. Once invoked, the embedding process will be terminated, and users will be charged for the embeddings processed up to the cancellation point. It's important to note that partial results will not be available to users after cancellation.

πŸ”Œ Usage

await client.embedJobs.cancel("id");

βš™οΈ Parameters

id: string β€” The ID of the embed job to cancel.

requestOptions: EmbedJobs.RequestOptions

Datasets

client.datasets.list({ ...params }) -> Cohere.DatasetsListResponse

πŸ“ Description

List datasets that have been created.

πŸ”Œ Usage

await client.datasets.list();

βš™οΈ Parameters

request: Cohere.DatasetsListRequest

requestOptions: Datasets.RequestOptions

client.datasets.create(data, evalData, { ...params }) -> Cohere.DatasetsCreateResponse

πŸ“ Description

Create a dataset by uploading a file. See 'Dataset Creation' for more information.

πŸ”Œ Usage

await client.datasets.create(fs.createReadStream("/path/to/your/file"), fs.createReadStream("/path/to/your/file"), {
    name: "name",
    type: "embed-input",
});

βš™οΈ Parameters

data: File | fs.ReadStream | Blob

evalData: File | fs.ReadStream | Blob | undefined

request: Cohere.DatasetsCreateRequest

requestOptions: Datasets.RequestOptions

client.datasets.getUsage() -> Cohere.DatasetsGetUsageResponse

πŸ“ Description

View the dataset storage usage for your Organization. Each Organization can have up to 10GB of storage across all their users.

πŸ”Œ Usage

await client.datasets.getUsage();

βš™οΈ Parameters

requestOptions: Datasets.RequestOptions

client.datasets.get(id) -> Cohere.DatasetsGetResponse

πŸ“ Description

Retrieve a dataset by ID. See 'Datasets' for more information.

πŸ”Œ Usage

await client.datasets.get("id");

βš™οΈ Parameters

id: string

requestOptions: Datasets.RequestOptions

client.datasets.delete(id) -> Record

πŸ“ Description

Delete a dataset by ID. Datasets are automatically deleted after 30 days, but they can also be deleted manually.

πŸ”Œ Usage

await client.datasets.delete("id");

βš™οΈ Parameters

id: string

requestOptions: Datasets.RequestOptions

Connectors

client.connectors.list({ ...params }) -> Cohere.ListConnectorsResponse

πŸ“ Description

Returns a list of connectors ordered by descending creation date (newer first). See 'Managing your Connector' for more information.

πŸ”Œ Usage

await client.connectors.list();

βš™οΈ Parameters

request: Cohere.ConnectorsListRequest

requestOptions: Connectors.RequestOptions

client.connectors.create({ ...params }) -> Cohere.CreateConnectorResponse

πŸ“ Description

Creates a new connector. The connector is tested during registration and will cancel registration when the test is unsuccessful. See 'Creating and Deploying a Connector' for more information.

πŸ”Œ Usage

await client.connectors.create({
    name: "name",
    url: "url",
});

βš™οΈ Parameters

request: Cohere.CreateConnectorRequest

requestOptions: Connectors.RequestOptions

client.connectors.get(id) -> Cohere.GetConnectorResponse

πŸ“ Description

Retrieve a connector by ID. See 'Connectors' for more information.

πŸ”Œ Usage

await client.connectors.get("id");

βš™οΈ Parameters

id: string β€” The ID of the connector to retrieve.

requestOptions: Connectors.RequestOptions

client.connectors.delete(id) -> Cohere.DeleteConnectorResponse

πŸ“ Description

Delete a connector by ID. See 'Connectors' for more information.

πŸ”Œ Usage

await client.connectors.delete("id");

βš™οΈ Parameters

id: string β€” The ID of the connector to delete.

requestOptions: Connectors.RequestOptions

client.connectors.update(id, { ...params }) -> Cohere.UpdateConnectorResponse

πŸ“ Description

Update a connector by ID. Omitted fields will not be updated. See 'Managing your Connector' for more information.

πŸ”Œ Usage

await client.connectors.update("id");

βš™οΈ Parameters

id: string β€” The ID of the connector to update.

request: Cohere.UpdateConnectorRequest

requestOptions: Connectors.RequestOptions

client.connectors.oAuthAuthorize(id, { ...params }) -> Cohere.OAuthAuthorizeResponse

πŸ“ Description

Authorize the connector with the given ID for the connector oauth app. See 'Connector Authentication' for more information.

πŸ”Œ Usage

await client.connectors.oAuthAuthorize("id");

βš™οΈ Parameters

id: string β€” The ID of the connector to authorize.

request: Cohere.ConnectorsOAuthAuthorizeRequest

requestOptions: Connectors.RequestOptions

Models

client.models.get(model) -> Cohere.GetModelResponse

πŸ“ Description

Returns the details of a model, provided its name.

πŸ”Œ Usage

await client.models.get("command-r");

βš™οΈ Parameters

model: string

requestOptions: Models.RequestOptions

client.models.list({ ...params }) -> Cohere.ListModelsResponse

πŸ“ Description

Returns a list of models available for use. The list contains models from Cohere as well as your fine-tuned models.

πŸ”Œ Usage

await client.models.list();

βš™οΈ Parameters

request: Cohere.ModelsListRequest

requestOptions: Models.RequestOptions

/finetuning

client.finetuning.listFinetunedModels({ ...params }) -> Cohere.ListFinetunedModelsResponse

πŸ”Œ Usage

await client.finetuning.listFinetunedModels();

βš™οΈ Parameters

request: Cohere.FinetuningListFinetunedModelsRequest

requestOptions: Finetuning.RequestOptions

client.finetuning.createFinetunedModel({ ...params }) -> Cohere.CreateFinetunedModelResponse

πŸ”Œ Usage

await client.finetuning.createFinetunedModel({
    name: "api-test",
    settings: {
        baseModel: {
            baseType: "BASE_TYPE_CHAT",
        },
        datasetId: "my-dataset-id",
    },
});

βš™οΈ Parameters

request: Cohere.FinetunedModel

requestOptions: Finetuning.RequestOptions

client.finetuning.getFinetunedModel(id) -> Cohere.GetFinetunedModelResponse

πŸ”Œ Usage

await client.finetuning.getFinetunedModel("id");

βš™οΈ Parameters

id: string β€” The fine-tuned model ID.

requestOptions: Finetuning.RequestOptions

client.finetuning.deleteFinetunedModel(id) -> Cohere.DeleteFinetunedModelResponse

πŸ”Œ Usage

await client.finetuning.deleteFinetunedModel("id");

βš™οΈ Parameters

id: string β€” The fine-tuned model ID.

requestOptions: Finetuning.RequestOptions

client.finetuning.updateFinetunedModel(id, { ...params }) -> Cohere.UpdateFinetunedModelResponse

πŸ”Œ Usage

await client.finetuning.updateFinetunedModel("id", {
    name: "name",
    settings: {
        baseModel: {
            baseType: "BASE_TYPE_UNSPECIFIED",
        },
        datasetId: "dataset_id",
    },
});

βš™οΈ Parameters

id: string β€” FinetunedModel ID.

request: Cohere.FinetuningUpdateFinetunedModelRequest

requestOptions: Finetuning.RequestOptions

client.finetuning.listEvents(finetunedModelId, { ...params }) -> Cohere.ListEventsResponse

πŸ”Œ Usage

await client.finetuning.listEvents("finetuned_model_id");

βš™οΈ Parameters

finetunedModelId: string β€” The parent fine-tuned model ID.

request: Cohere.FinetuningListEventsRequest

requestOptions: Finetuning.RequestOptions

client.finetuning.listTrainingStepMetrics(finetunedModelId, { ...params }) -> Cohere.ListTrainingStepMetricsResponse

πŸ”Œ Usage

await client.finetuning.listTrainingStepMetrics("finetuned_model_id");

βš™οΈ Parameters

finetunedModelId: string β€” The parent fine-tuned model ID.

request: Cohere.FinetuningListTrainingStepMetricsRequest

requestOptions: Finetuning.RequestOptions