Files
llmx/sdk/typescript
Sebastian Krüger c493ea1347 Phase 5: Configuration & Documentation
Updated all documentation and configuration files:

Documentation changes:
- Updated README.md to describe LLMX as LiteLLM-powered fork
- Updated CLAUDE.md with LiteLLM integration details
- Updated 50+ markdown files across docs/, llmx-rs/, llmx-cli/, sdk/
- Changed all references: codex → llmx, Codex → LLMX
- Updated package references: @openai/codex → @llmx/llmx
- Updated repository URLs: github.com/openai/codex → github.com/valknar/llmx

Configuration changes:
- Updated .github/dependabot.yaml
- Updated .github workflow files
- Updated cliff.toml (changelog configuration)
- Updated Cargo.toml comments

Key branding updates:
- Project description: "coding agent from OpenAI" → "coding agent powered by LiteLLM"
- Added attribution to original OpenAI Codex project
- Documented LiteLLM integration benefits

Files changed: 51 files (559 insertions, 559 deletions)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-11 14:45:40 +01:00
..
2025-10-01 12:39:04 -07:00
2025-10-01 12:39:04 -07:00
2025-09-29 13:27:13 -07:00

LLMX SDK

Embed the LLMX agent in your workflows and apps.

The TypeScript SDK wraps the bundled llmx binary. It spawns the CLI and exchanges JSONL events over stdin/stdout.

Installation

npm install @llmx/llmx-sdk

Requires Node.js 18+.

Quickstart

import { LLMX } from "@llmx/llmx-sdk";

const llmx = new LLMX();
const thread = llmx.startThread();
const turn = await thread.run("Diagnose the test failure and propose a fix");

console.log(turn.finalResponse);
console.log(turn.items);

Call run() repeatedly on the same Thread instance to continue that conversation.

const nextTurn = await thread.run("Implement the fix");

Streaming responses

run() buffers events until the turn finishes. To react to intermediate progress—tool calls, streaming responses, and file change notifications—use runStreamed() instead, which returns an async generator of structured events.

const { events } = await thread.runStreamed("Diagnose the test failure and propose a fix");

for await (const event of events) {
  switch (event.type) {
    case "item.completed":
      console.log("item", event.item);
      break;
    case "turn.completed":
      console.log("usage", event.usage);
      break;
  }
}

Structured output

The LLMX agent can produce a JSON response that conforms to a specified schema. The schema can be provided for each turn as a plain JSON object.

const schema = {
  type: "object",
  properties: {
    summary: { type: "string" },
    status: { type: "string", enum: ["ok", "action_required"] },
  },
  required: ["summary", "status"],
  additionalProperties: false,
} as const;

const turn = await thread.run("Summarize repository status", { outputSchema: schema });
console.log(turn.finalResponse);

You can also create a JSON schema from a Zod schema using the zod-to-json-schema package and setting the target to "openAi".

const schema = z.object({
  summary: z.string(),
  status: z.enum(["ok", "action_required"]),
});

const turn = await thread.run("Summarize repository status", {
  outputSchema: zodToJsonSchema(schema, { target: "openAi" }),
});
console.log(turn.finalResponse);

Attaching images

Provide structured input entries when you need to include images alongside text. Text entries are concatenated into the final prompt while image entries are passed to the LLMX CLI via --image.

const turn = await thread.run([
  { type: "text", text: "Describe these screenshots" },
  { type: "local_image", path: "./ui.png" },
  { type: "local_image", path: "./diagram.jpg" },
]);

Resuming an existing thread

Threads are persisted in ~/.llmx/sessions. If you lose the in-memory Thread object, reconstruct it with resumeThread() and keep going.

const savedThreadId = process.env.CODEX_THREAD_ID!;
const thread = llmx.resumeThread(savedThreadId);
await thread.run("Implement the fix");

Working directory controls

LLMX runs in the current working directory by default. To avoid unrecoverable errors, LLMX requires the working directory to be a Git repository. You can skip the Git repository check by passing the skipGitRepoCheck option when creating a thread.

const thread = llmx.startThread({
  workingDirectory: "/path/to/project",
  skipGitRepoCheck: true,
});