| 1 | package Langertha::Engine::Scaleway; | ||||||||||||||||||||
| 2 | # ABSTRACT: Scaleway Generative APIs | ||||||||||||||||||||
| 3 | 10 | our $VERSION = '0.503'; | |||||||||||||||||||
| 4 | 10 | ▶ | use Moose; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 10 | ▶ | use Carp qw( croak ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 10 | extends 'Langertha::Engine::OpenAIBase'; | |||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 10 | with 'Langertha::Role::Embedding', 'Langertha::Role::Tools'; | |||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | has '+url' => ( | ||||||||||||||||||||
| 13 | lazy => 1, | ||||||||||||||||||||
| 14 | 14 | ▶ | default => sub { 'https://api.scaleway.ai/v1' }, | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 15 | 10 | ); | |||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 1 | ▶ | sub _build_api_key { | ||||||||||||||||||
|
Subroutine
_build_api_key: called CC=2 SCAR=8.1
| |||||||||||||||||||||
| 18 | 1 | my ( $self ) = @_; | |||||||||||||||||||
| 19 | return $ENV{LANGERTHA_SCALEWAY_API_KEY} | ||||||||||||||||||||
| 20 | 1 | ▶ | || croak "".(ref $self)." requires LANGERTHA_SCALEWAY_API_KEY or api_key set"; | ||||||||||||||||||
|
Condition33%1/3
$ENV{'LANGERTHA_SCALEWAY_API_KEY'} || croak('' . ref($self) . ' requires LANGERTHA_SCALEWAY_API_KEY or api_key set')
MC/DC0%0/2
$ENV{'LANGERTHA_SCALEWAY_API_KEY'} || croak('' . ref($self) . ' requires LANGERTHA_SCALEWAY_API_KEY or api_key set')
$ENV{'LANGERTHA_SCALEWAY_API_KEY'}
croak('' . ref($self) . ' requires LANGERTHA_SCALEWAY_API_KEY or api_key set')
Truth table33%1/3
A || B
A= $ENV{'LANGERTHA_SCALEWAY_API_KEY'}B= croak('' . ref($self) . ' requires LANGERTHA_SCALEWAY_API_KEY or api_key set')
| |||||||||||||||||||||
| 21 | } | ||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | # llama-3.1-8b-instruct went EOL on Scaleway's serverless tier (supported-models | ||||||||||||||||||||
| 24 | # page, 2026-09-25); llama-3.3-70b-instruct is still served (k307). | ||||||||||||||||||||
| 25 | 16 | ▶ | sub default_model { 'llama-3.3-70b-instruct' } | ||||||||||||||||||
|
Subroutine
default_model: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | # Scaleway's embedding model (supported-models list, llm-advisor 2026-09-25; | ||||||||||||||||||||
| 28 | # bge-multilingual-gemma2 is also served). The OpenAI role's | ||||||||||||||||||||
| 29 | # text-embedding-3-large is not (k291). | ||||||||||||||||||||
| 30 | 2 | ▶ | sub default_embedding_model { 'qwen3-embedding-8b' } | ||||||||||||||||||
|
Subroutine
default_embedding_model: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | # Undocumented: the embeddings API docs list dimensions as unsupported (k319). | ||||||||||||||||||||
| 33 | 2 | ▶ | sub _embedding_dimensions_field { undef } | ||||||||||||||||||
|
Subroutine
_embedding_dimensions_field: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | # Scaleway's Generative APIs narrow two flags the OpenAI role inventory grants | ||||||||||||||||||||
| 36 | # (scaleway.com/en/docs/generative-apis, verified 2026-09-01): | ||||||||||||||||||||
| 37 | # * parallel_tool_calls is accepted but INERT — "even if set false this | ||||||||||||||||||||
| 38 | # parameter will be ignored and act as if set to true". A silently-ignored | ||||||||||||||||||||
| 39 | # control is worse than a rejected one, so clear parallel_tool_use. | ||||||||||||||||||||
| 40 | # * response_format json_object is deprecated ("should not be used anymore"); | ||||||||||||||||||||
| 41 | # json_schema is the supported structured-output path, so clear json_object | ||||||||||||||||||||
| 42 | # and keep json_schema. | ||||||||||||||||||||
| 43 | # NOT cleared: tool_choice_any. Scaleway's tool_choice enum is | ||||||||||||||||||||
| 44 | # none|auto|required, and Langertha's canonical `any` serializes to the wire | ||||||||||||||||||||
| 45 | # `required` (Langertha::ToolChoice::to_openai), which Scaleway accepts. (The | ||||||||||||||||||||
| 46 | # k138 matrix flagged tool_choice_any here by reading OpenAI's non-existent | ||||||||||||||||||||
| 47 | # literal "any"; the canonical mapping makes the flag correct as-is.) | ||||||||||||||||||||
| 48 | 99 | ▶ | around engine_capabilities => sub { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 49 | 99 | my ( $orig, $self, @rest ) = @_; | |||||||||||||||||||
| 50 | 99 | my $caps = $self->$orig(@rest); | |||||||||||||||||||
| 51 | 99 | delete @{$caps}{ qw( parallel_tool_use response_format_json_object ) }; | |||||||||||||||||||
| 52 | 99 | return $caps; | |||||||||||||||||||
| 53 | 10 | }; | |||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | # image_input (k266, ADR 0019 k266 Update): Scaleway serves text-only and | ||||||||||||||||||||
| 56 | # vision models side by side (llm-advisor, docs only, 2026-09-25). The | ||||||||||||||||||||
| 57 | # catch-all first row clears the flag (the text-only default | ||||||||||||||||||||
| 58 | # llama-3.3-70b-instruct makes no claim); the vision families re-assert it. | ||||||||||||||||||||
| 59 | 99 | ▶ | sub model_capability_corrections { | ||||||||||||||||||
|
Subroutine
model_capability_corrections: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 60 | return ( | ||||||||||||||||||||
| 61 | 99 | qr/\A/ => { image_input => 0 }, | |||||||||||||||||||
| 62 | qr/\A(?:pixtral-|mistral-small-3\.[12]|mistral-large-3|gemma-3-27b|gemma-4|qwen3\.[56]-|holo2|molmo)/ | ||||||||||||||||||||
| 63 | => { image_input => 1 }, | ||||||||||||||||||||
| 64 | ); | ||||||||||||||||||||
| 65 | } | ||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | 25 | ▶ | sub _build_supported_operations {[qw( | ||||||||||||||||||
|
Subroutine
_build_supported_operations: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 68 | createChatCompletion | ||||||||||||||||||||
| 69 | createEmbedding | ||||||||||||||||||||
| 70 | )]} | ||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | 10 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | 10 | 1; | |||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | __END__ | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | =pod | ||||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | =encoding UTF-8 | ||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | =head1 NAME | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | Langertha::Engine::Scaleway - Scaleway Generative APIs | ||||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | =head1 VERSION | ||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | version 0.503 | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | =head1 SYNOPSIS | ||||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | use Langertha::Engine::Scaleway; | ||||||||||||||||||||
| 94 | |||||||||||||||||||||
| 95 | my $scw = Langertha::Engine::Scaleway->new( | ||||||||||||||||||||
| 96 | api_key => $ENV{LANGERTHA_SCALEWAY_API_KEY}, | ||||||||||||||||||||
| 97 | model => 'llama-3.3-70b-instruct', | ||||||||||||||||||||
| 98 | ); | ||||||||||||||||||||
| 99 | |||||||||||||||||||||
| 100 | print $scw->simple_chat('Hello from Scaleway!'); | ||||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | =head1 DESCRIPTION | ||||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | Provides access to B<Scaleway Generative APIs>, a serverless inference service | ||||||||||||||||||||
| 105 | hosted in European data centers. Composes L<Langertha::Role::OpenAICompatible> | ||||||||||||||||||||
| 106 | with Scaleway's endpoint (C<https://api.scaleway.ai/v1>) and Bearer auth. | ||||||||||||||||||||
| 107 | |||||||||||||||||||||
| 108 | Scaleway is designed as a drop-in replacement for the OpenAI API and is | ||||||||||||||||||||
| 109 | EU-act compliant. Available chat models include C<llama-3.3-70b-instruct> | ||||||||||||||||||||
| 110 | (default), C<mistral-small-3.2-24b-instruct-2506>, C<gemma-3-27b-it> and | ||||||||||||||||||||
| 111 | others; see Scaleway's supported-models page for which are still served. Function calling, structured output and | ||||||||||||||||||||
| 112 | embeddings are supported; the default embedding model is | ||||||||||||||||||||
| 113 | C<qwen3-embedding-8b> (C<bge-multilingual-gemma2> is also served, set it | ||||||||||||||||||||
| 114 | with C<embedding_model>). | ||||||||||||||||||||
| 115 | |||||||||||||||||||||
| 116 | L<Langertha::Role::Embedding/embedding_dimensions> is not sent (it carps | ||||||||||||||||||||
| 117 | once): Scaleway's embeddings API documentation lists C<dimensions> under its | ||||||||||||||||||||
| 118 | unsupported parameters. Pass a C<dimensions> extra to C<embedding_request> to | ||||||||||||||||||||
| 119 | send it anyway. | ||||||||||||||||||||
| 120 | |||||||||||||||||||||
| 121 | If you want to scope requests to a specific Scaleway project, override C<url> | ||||||||||||||||||||
| 122 | with C<https://api.scaleway.ai/E<lt>PROJECT_IDE<gt>/v1>. | ||||||||||||||||||||
| 123 | |||||||||||||||||||||
| 124 | Generate an API secret key in the Scaleway console | ||||||||||||||||||||
| 125 | (L<https://console.scaleway.com/>) and set C<LANGERTHA_SCALEWAY_API_KEY>. | ||||||||||||||||||||
| 126 | |||||||||||||||||||||
| 127 | B<THIS API IS WORK IN PROGRESS> | ||||||||||||||||||||
| 128 | |||||||||||||||||||||
| 129 | =head1 SEE ALSO | ||||||||||||||||||||
| 130 | |||||||||||||||||||||
| 131 | =over | ||||||||||||||||||||
| 132 | |||||||||||||||||||||
| 133 | =item * L<https://www.scaleway.com/en/docs/generative-apis/> - Scaleway Generative APIs documentation | ||||||||||||||||||||
| 134 | |||||||||||||||||||||
| 135 | =item * L<https://www.scaleway.com/en/generative-apis/> - Scaleway Generative APIs product page | ||||||||||||||||||||
| 136 | |||||||||||||||||||||
| 137 | =item * L<https://www.scaleway.com/en/docs/generative-apis/reference-content/supported-models/> - Supported chat and embedding models | ||||||||||||||||||||
| 138 | |||||||||||||||||||||
| 139 | =item * L<Langertha::Role::OpenAICompatible> - OpenAI API format role | ||||||||||||||||||||
| 140 | |||||||||||||||||||||
| 141 | =back | ||||||||||||||||||||
| 142 | |||||||||||||||||||||
| 143 | =head1 SUPPORT | ||||||||||||||||||||
| 144 | |||||||||||||||||||||
| 145 | =head2 Issues | ||||||||||||||||||||
| 146 | |||||||||||||||||||||
| 147 | Please report bugs and feature requests on GitHub at | ||||||||||||||||||||
| 148 | L<https://github.com/Getty/langertha/issues>. | ||||||||||||||||||||
| 149 | |||||||||||||||||||||
| 150 | =head2 IRC | ||||||||||||||||||||
| 151 | |||||||||||||||||||||
| 152 | Join C<#langertha> on C<irc.perl.org> or message Getty directly. | ||||||||||||||||||||
| 153 | |||||||||||||||||||||
| 154 | =head1 CONTRIBUTING | ||||||||||||||||||||
| 155 | |||||||||||||||||||||
| 156 | Contributions are welcome! Please fork the repository and submit a pull request. | ||||||||||||||||||||
| 157 | |||||||||||||||||||||
| 158 | =head1 AUTHOR | ||||||||||||||||||||
| 159 | |||||||||||||||||||||
| 160 | Torsten Raudssus <getty@cpan.org> | ||||||||||||||||||||
| 161 | |||||||||||||||||||||
| 162 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||
| 163 | |||||||||||||||||||||
| 164 | This software is copyright (c) 2026 by Torsten Raudssus L<https://raudssus.de/>. | ||||||||||||||||||||
| 165 | |||||||||||||||||||||
| 166 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||
| 167 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||
| 168 | |||||||||||||||||||||
| 169 | =cut | ||||||||||||||||||||