Class CompletionsAPI

Constructors

Properties

Methods

Constructors

Properties

client: Client

Methods

  • Create a non-streaming Completions request.

    Parameters

    • request: CreateCompletionRequestNonStream

      The non-streaming Completions request.

    • Optional endpoint: string

      An optional custom endpoint to call. If not provided, the endpoint defaults to https://text.octoai.run/v1/completions.

    Returns Promise<CreateCompletionResponse>

    Example

    import { Client } from "@octoai/client";

    const client = new Client(process.env.OCTOAI_TOKEN);

    const response = await client.create({
    model: "llama-2-13b-chat",
    prompt: "Write a blog about Seattle",
    });

    console.log(response.choices[0].text);
    // Seattle is a vibrant and eclectic city...
  • Create a streaming Completions request.

    Parameters

    • request: CreateCompletionRequestStream

      The streaming Completions request.

    • Optional endpoint: string

      An optional custom endpoint to call. If not provided, the endpoint defaults to https://text.octoai.run/v1/completions or the secureLink API if secureLink is set to true on client instantiation.

    Returns Promise<Stream<CreateCompletionResponse>>

    Example

    import { Client } from "@octoai/client";

    const client = new Client(process.env.OCTOAI_TOKEN);

    const stream = await client.create({
    model: "llama-2-13b-chat",
    prompt: "Write a blog about Seattle",
    stream: true,
    });

    let result = "";

    for await (const chunk of stream) {
    result += chunk.choices[0].text;
    }

    stream.controller.abort();

    console.log(result);
    // Seattle is a vibrant and eclectic city...

Generated using TypeDoc