Skip to content

Latest commit

 

History

History
1858 lines (1290 loc) · 21.9 KB

reference.md

File metadata and controls

1858 lines (1290 loc) · 21.9 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 message from the model in response to a provided conversation. To learn more about the features of the Chat API follow our Text Generation guides.

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

🔌 Usage

await client.v2.chatStream({
    model: "string",
    messages: [
        {
            role: "user",
            content: "string",
        },
    ],
    tools: [
        {
            type: "function",
            function: {
                name: "string",
                description: "string",
                parameters: {
                    string: {
                        key: "value",
                    },
                },
            },
        },
    ],
    documents: ["string"],
    citationOptions: {
        mode: Cohere.CitationOptionsMode.Fast,
    },
    responseFormat: {
        type: "text",
    },
    safetyMode: Cohere.V2ChatStreamRequestSafetyMode.Contextual,
    maxTokens: 1,
    stopSequences: ["string"],
    temperature: 1.1,
    seed: 1,
    frequencyPenalty: 1.1,
    presencePenalty: 1.1,
    k: 1.1,
    p: 1.1,
    returnPrompt: true,
});

⚙️ Parameters

request: Cohere.V2ChatStreamRequest

requestOptions: V2.RequestOptions

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

📝 Description

Generates a message from the model in response to a provided conversation. To learn more about the features of the Chat API 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",
        },
    ],
});

⚙️ 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: Cohere.EmbedInputType.SearchDocument,
    embeddingTypes: [Cohere.EmbeddingType.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: Cohere.EmbedInputType.SearchDocument,
});

⚙️ 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: Cohere.DatasetType.EmbedInput,
});

⚙️ 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: Cohere.BaseType.BaseTypeChat,
        },
        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: Cohere.BaseType.BaseTypeUnspecified,
        },
        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