llm-service-integration
Abstracts LLM provider integration in the DEVS platform to ensure provider-agnostic AI feature development.
Install
mkdir -p .claude/skills/llm-service-integration && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/10452" && unzip -o skill.zip -d .claude/skills/llm-service-integration && rm skill.zipInstalls to .claude/skills/llm-service-integration
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Guide for integrating with LLM providers in the DEVS platform. Use this when asked to add LLM functionality, create AI-powered features, or work with the LLM service.Key capabilities
- →Abstract LLM providers
- →Configure temperature and tokens
- →Stream chat responses
- →Extract structured JSON
How it works
It provides a unified service layer that abstracts various LLM providers, handling configuration and streaming consistently.
Inputs & outputs
When to use llm-service-integration
- →Add LLM-powered features to the DEVS platform
- →Switch between Anthropic and OpenAI providers
- →Implement streaming chat UI responses
About this skill
LLM Service Integration for DEVS
When working with LLM functionality in the DEVS platform, always use the abstracted LLM service layer. Never call provider APIs directly.
Core Principle
DEVS is provider-agnostic. The LLMService in src/lib/llm/ abstracts multiple providers:
- OpenAI
- Anthropic (Claude)
- Google Gemini
- Mistral
- Ollama (local)
- Custom endpoints
Basic Usage
import { LLMService } from '@/lib/llm'
import type { Message } from '@/types'
async function generateResponse(userPrompt: string): Promise<string> {
const messages: Message[] = [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: userPrompt },
]
const response = await LLMService.chat(messages, {
temperature: 0.7,
maxTokens: 2000,
})
return response.content
}
Message Types
interface Message {
role: 'system' | 'user' | 'assistant'
content: string
name?: string // For multi-agent conversations
}
Configuration Options
interface LLMConfig {
temperature?: number // 0-1, default 0.7
maxTokens?: number // Max response tokens
model?: string // Override default model
stream?: boolean // Enable streaming
topP?: number // Nucleus sampling
frequencyPenalty?: number // Reduce repetition
presencePenalty?: number // Encourage new topics
}
Streaming Responses
For real-time UI updates:
import { LLMService } from '@/lib/llm'
async function streamResponse(
messages: Message[],
onChunk: (text: string) => void,
): Promise<string> {
let fullResponse = ''
await LLMService.streamChat(messages, {
onChunk: (chunk) => {
fullResponse += chunk
onChunk(chunk)
},
temperature: 0.7,
})
return fullResponse
}
Error Handling
Always wrap LLM calls in try/catch:
import { LLMService } from '@/lib/llm'
import { toast } from '@/lib/toast'
async function safeGenerate(prompt: string): Promise<string | null> {
try {
const response = await LLMService.chat([{ role: 'user', content: prompt }])
return response.content
} catch (error) {
console.error('LLM call failed:', error)
toast.error('Failed to generate response. Please try again.')
return null
}
}
Agent Context Integration
When generating responses for agents, include their instructions:
import { LLMService } from '@/lib/llm'
import { getAgentById } from '@/stores/agentStore'
import type { Agent, Message } from '@/types'
async function generateAgentResponse(
agentId: string,
conversationHistory: Message[],
userMessage: string,
): Promise<string> {
const agent = getAgentById(agentId)
if (!agent) throw new Error('Agent not found')
const messages: Message[] = [
{
role: 'system',
content: buildAgentSystemPrompt(agent),
},
...conversationHistory,
{ role: 'user', content: userMessage },
]
const response = await LLMService.chat(messages, {
temperature: agent.temperature ?? 0.7,
})
return response.content
}
function buildAgentSystemPrompt(agent: Agent): string {
return `You are ${agent.name}, ${agent.role}.
${agent.instructions}
Always stay in character and respond according to your role and expertise.`
}
Structured Output (JSON)
For extracting structured data:
import { LLMService } from '@/lib/llm'
interface ExtractedData {
title: string
summary: string
keywords: string[]
}
async function extractStructuredData(text: string): Promise<ExtractedData> {
const response = await LLMService.chat(
[
{
role: 'system',
content: `Extract information from the text and return as JSON:
{
"title": "string",
"summary": "string",
"keywords": ["string"]
}
Return ONLY valid JSON, no other text.`,
},
{ role: 'user', content: text },
],
{
temperature: 0.3, // Lower for more deterministic output
},
)
// Parse with error handling
try {
return JSON.parse(response.content)
} catch {
// Attempt to extract JSON from response
const jsonMatch = response.content.match(/\{[\s\S]*\}/)
if (jsonMatch) {
return JSON.parse(jsonMatch[0])
}
throw new Error('Failed to parse LLM response as JSON')
}
}
Cost & Usage Tracking
The platform tracks LLM usage via the traces feature. Include metadata when relevant:
import { LLMService } from '@/lib/llm'
const response = await LLMService.chat(messages, {
metadata: {
feature: 'task-analysis',
agentId: agent.id,
taskId: task.id,
},
})
Testing LLM Integration
Mock the LLM service in tests:
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { LLMService } from '@/lib/llm'
vi.mock('@/lib/llm', () => ({
LLMService: {
chat: vi.fn(),
streamChat: vi.fn(),
},
}))
describe('MyFeature', () => {
beforeEach(() => {
vi.clearAllMocks()
})
it('should process LLM response correctly', async () => {
vi.mocked(LLMService.chat).mockResolvedValue({
content: '{"result": "success"}',
usage: { promptTokens: 100, completionTokens: 50 },
})
const result = await myFunction()
expect(result).toEqual({ result: 'success' })
})
})
Common Patterns
Task Analysis
See src/lib/task-analyzer.ts for breaking down complex prompts.
Conversation Title Generation
See src/lib/conversation-title-generator.ts for generating chat titles.
Memory Learning
See src/lib/memory-learning-service.ts for extracting learnable facts from conversations.
Requirement Validation
See src/lib/requirement-validator.ts for validating task deliverables.
When not to use it
- →Direct API calls
- →Non-LLM service tasks
Prerequisites
Limitations
- →Requires provider-specific configuration
- →JSON parsing depends on LLM output quality
How it compares
It decouples the application from specific LLM providers, allowing for easy switching and consistent configuration management.
Compared to similar skills
llm-service-integration side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| llm-service-integration (this skill) | 0 | 6mo | No flags | Intermediate |
| mcp-builder | 0 | 2mo | No flags | Advanced |
| mcp-builder | 136 | 3mo | Review | Advanced |
| copilot-sdk | 7 | 4mo | Review | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
mcp-builder
UnderUndreGH
MCP (Model Context Protocol) server building principles. Tool design, resource patterns, best practices.
mcp-builder
anthropics
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).
copilot-sdk
github
Build agentic applications with GitHub Copilot SDK. Use when embedding AI agents in apps, creating custom tools, implementing streaming responses, managing sessions, connecting to MCP servers, or creating custom agents. Triggers on Copilot SDK, GitHub SDK, agentic app, embed Copilot, programmable agent, MCP server, custom agent.
chatgpt-app-builder
mcp-use
Build ChatGPT apps with interactive widgets using mcp-use and OpenAI Apps SDK. Use when creating ChatGPT apps, building MCP servers with widgets, defining React widgets, working with Apps SDK, or when user mentions ChatGPT widgets, mcp-use widgets, or Apps SDK development.
openrouter-hello-world
jeremylongshore
Create your first OpenRouter API request with a simple example. Use when learning OpenRouter or testing your setup. Trigger with phrases like 'openrouter hello world', 'openrouter first request', 'openrouter quickstart', 'test openrouter'.
create-mcp-app
modelcontextprotocol
This skill should be used when the user asks to "create an MCP App", "add a UI to an MCP tool", "build an interactive MCP View", "scaffold an MCP App", or needs guidance on MCP Apps SDK patterns, UI-resource registration, MCP App lifecycle, or host integration. Provides comprehensive guidance for building MCP Apps with interactive UIs.