NAME

Langertha::Engine::LMStudio - LM Studio native REST API

VERSION

version 0.305

SYNOPSIS

use Langertha::Engine::LMStudio;

my $lmstudio = Langertha::Engine::LMStudio->new(
    url   => 'http://localhost:1234',
    model => 'qwen2.5-7b-instruct',
);

print $lmstudio->simple_chat('Hello from LM Studio native API');

$lmstudio->simple_chat_stream(sub {
    print shift->content;
}, 'Explain Perl Moo vs Moose');

DESCRIPTION

Provides access to LM Studio's native local REST API (/api/v1/...), without using the OpenAI-compatible /v1 endpoints.

Implemented operations:

  • Chat: POST /api/v1/chat

  • Streaming chat (SSE): stream = true>

  • Model listing: GET /api/v1/models

  • OpenAI-compatible wrapper via "openai" (/v1)

  • Anthropic-compatible wrapper via "anthropic" (/v1/messages)

Authentication is optional. If api_key (or LANGERTHA_LMSTUDIO_API_KEY) is set, requests include Authorization: Bearer ....

THIS API IS WORK IN PROGRESS

api_key

Optional LM Studio API token for bearer authentication. If not provided, reads from LANGERTHA_LMSTUDIO_API_KEY. When undefined, no bearer header is sent.

openapi_file

Returns the bundled native LM Studio OpenAPI spec file share/lmstudio.yaml.

openai

my $oai = $lmstudio->openai;
my $oai = $lmstudio->openai(model => 'other-model');

Returns a Langertha::Engine::LMStudioOpenAI instance configured for LM Studio's OpenAI-compatible /v1 endpoint. Carries over model, api_key, system_prompt, and temperature by default.

anthropic

my $anthropic = $lmstudio->anthropic;
my $anthropic = $lmstudio->anthropic(model => 'other-model');

Returns a Langertha::Engine::LMStudioAnthropic instance configured for LM Studio's Anthropic-compatible /v1/messages endpoint. Carries over model, api_key, system_prompt, and temperature by default.

SEE ALSO

SUPPORT

Issues

Please report bugs and feature requests on GitHub at https://github.com/Getty/langertha/issues.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHOR

Torsten Raudssus <torsten@raudssus.de> https://raudss.us/

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.