···11-import { API_BASE_URL, API_PARAMS, API_TIMEOUT_MS } from "./config";
11+import { API_PARAMS, API_TIMEOUT_MS } from "./config";
22import type { ApiErrorResponse, ApiChatCompletionStreamChunk } from "./types/api";
3344/** Error thrown when the API call fails for any reason (network, HTTP, malformed response). */
···2121 *
2222 * @param text - Validated, non-empty input text
2323 * @param systemPrompt - System prompt to instruct the model
2424+ * @param baseUrl - API server base URL (e.g. "http://localhost:8080")
2425 * @yields Individual content tokens from the model's stream
2526 * @throws {@link ApiError} on timeout, HTTP errors, or network failures
2627 */
2728export async function* streamCorrection(
2829 text: string,
2930 systemPrompt: string,
3131+ baseUrl: string,
3032): AsyncGenerator<string, void, undefined> {
3133 const controller = new AbortController();
3234 const timeout = setTimeout(() => controller.abort(), API_TIMEOUT_MS);
···3436 let response: Response;
35373638 try {
3737- response = await fetch(`${API_BASE_URL}/v1/chat/completions`, {
3939+ response = await fetch(`${baseUrl}/v1/chat/completions`, {
3840 method: "POST",
3941 headers: { "Content-Type": "application/json" },
4042 body: JSON.stringify({
···5759 }
58605961 throw new ApiError(
6060- `Failed to connect to API at ${API_BASE_URL}. Is llama.cpp server running?`,
6262+ `Failed to connect to API at ${baseUrl}. Is llama.cpp server running?`,
6163 undefined,
6264 err,
6365 );
···8284 switch (status) {
8385 case 404:
8486 throw new ApiError(
8585- `API endpoint not found (404). Is llama.cpp server running at ${API_BASE_URL}?`,
8787+ `API endpoint not found (404). Is llama.cpp server running at ${baseUrl}?`,
8688 status,
8789 );
8890 case 429:
···11import type { ApiChatCompletionRequest } from "./types/api";
2233-/** Base URL of the llama.cpp server (OpenAI-compatible API). */
33+/** Default base URL of the OpenAI-compatible API server. */
44export const API_BASE_URL = "http://localhost:8080";
55+66+/** Storage key for the configurable API base URL. */
77+export const STORAGE_KEY_API_URL = "apiBaseUrl";
5869/** Shared tone rules appended to every prompt. */
710const TONE_RULES = `# Tone