LINKORA
OverviewQuickstart

Effect AI SDK

Integrate Linkora using the Effect AI SDK

Effect AI SDK

You can use the Effect AI SDK to integrate Linkora with your Effect applications. To get started, install the following packages:

npm install effect @effect/ai @effect/ai-linkora @effect/platform

Once that's done you can use the LanguageModel module to define interactions with a large language model via Linkora.

import { LanguageModel } from "@effect/ai"
import { LinkoraClient, LinkoraLanguageModel } from "@effect/ai-linkora"
import { FetchHttpClient } from "@effect/platform"
import { Config, Effect, Layer, Stream } from "effect"

const Gpt4o = LinkoraLanguageModel.model("openai/gpt-4o")

const program = LanguageModel.streamText({
  prompt: [
    { role: "system", content: "You are a comedian with a penchant for groan-inducing puns" },
    { role: "user", content: [{ type: "text", text: "Tell me a dad joke" }] }
  ]
}).pipe(
  Stream.filter((part) => part.type === "text-delta"),
  Stream.runForEach((part) => Effect.sync(() => process.stdout.write(part.delta))),
  Effect.provide(Gpt4o)
)

const Linkora = LinkoraClient.layerConfig({
  apiKey: Config.redacted("LINKORA_API_KEY")
}).pipe(Layer.provide(FetchHttpClient.layer))

program.pipe(
  Effect.provide(Linkora),
  Effect.runPromise
)