Higher-order fetch wrapper that injects auth token and session headers for official APIs.
// Source: https://github.com/moeru-ai/airi | License: MIT | Copyright 2024-PRESENT Neko Ayaka
// Provided via justclaw.it.com; keep this notice with the code.
import { createOpenAI } from '@xsai-ext/providers/create'
import { getActivePinia } from 'pinia'
import { getAuthToken } from '../../../../libs/auth'
import { SERVER_URL } from '../../../../libs/server'
import { useChatSessionStore } from '../../../../stores/chat/session-store'
import { AIRI_CHAT_SESSION_ID_HEADER } from '../../../product-signals/headers'
export const OFFICIAL_ICON = 'i-solar:star-bold-duotone'
export function withCredentials() {
return (input: RequestInfo | URL, init?: RequestInit) => {
const headers = new Headers(init?.headers)
const token = getAuthToken()
if (token) {
headers.set('Authoriza
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key