litellm/llms/anthropic/skills/readme.md
This module provides comprehensive support for the Anthropic Skills API through LiteLLM.
The Skills API allows you to:
Set your Anthropic API key:
import os
os.environ["ANTHROPIC_API_KEY"] = "your-api-key-here"
import litellm
# Create a skill with files
# Note: All files must be in the same top-level directory
# and must include a SKILL.md file at the root
skill = litellm.create_skill(
files=[
# List of file objects to upload
# Must include SKILL.md
],
display_title="Python Code Generator",
custom_llm_provider="anthropic"
)
print(f"Created skill: {skill.id}")
# Asynchronous version
skill = await litellm.acreate_skill(
files=[...], # Your files here
display_title="Python Code Generator",
custom_llm_provider="anthropic"
)
# List all skills
skills = litellm.list_skills(
custom_llm_provider="anthropic"
)
for skill in skills.data:
print(f"{skill.display_title}: {skill.id}")
# With pagination and filtering
skills = litellm.list_skills(
limit=20,
source="custom", # Filter by 'custom' or 'anthropic'
custom_llm_provider="anthropic"
)
# Get next page if available
if skills.has_more:
next_page = litellm.list_skills(
page=skills.next_page,
custom_llm_provider="anthropic"
)
skill = litellm.get_skill(
skill_id="skill_abc123",
custom_llm_provider="anthropic"
)
print(f"Skill: {skill.display_title}")
print(f"Created: {skill.created_at}")
print(f"Latest version: {skill.latest_version}")
print(f"Source: {skill.source}")
result = litellm.delete_skill(
skill_id="skill_abc123",
custom_llm_provider="anthropic"
)
print(f"Deleted skill {result.id}, type: {result.type}")
create_skill()Create a new skill.
Parameters:
files (List[Any], optional): Files to upload for the skill. All files must be in the same top-level directory and must include a SKILL.md file at the root.display_title (str, optional): Display title for the skillcustom_llm_provider (str, optional): Provider name (default: "anthropic")extra_headers (dict, optional): Additional HTTP headerstimeout (float, optional): Request timeoutReturns:
Skill: The created skill objectAsync version: acreate_skill()
list_skills()List all skills.
Parameters:
limit (int, optional): Number of results to return per page (max 100, default 20)page (str, optional): Pagination token for fetching a specific page of resultssource (str, optional): Filter skills by source ('custom' or 'anthropic')custom_llm_provider (str, optional): Provider name (default: "anthropic")extra_headers (dict, optional): Additional HTTP headerstimeout (float, optional): Request timeoutReturns:
ListSkillsResponse: Object containing a list of skills and pagination infoAsync version: alist_skills()
get_skill()Get a specific skill by ID.
Parameters:
skill_id (str, required): The skill IDcustom_llm_provider (str, optional): Provider name (default: "anthropic")extra_headers (dict, optional): Additional HTTP headerstimeout (float, optional): Request timeoutReturns:
Skill: The requested skill objectAsync version: aget_skill()
delete_skill()Delete a skill.
Parameters:
skill_id (str, required): The skill ID to deletecustom_llm_provider (str, optional): Provider name (default: "anthropic")extra_headers (dict, optional): Additional HTTP headerstimeout (float, optional): Request timeoutReturns:
DeleteSkillResponse: Object with id and type fieldsAsync version: adelete_skill()
SkillRepresents a skill from the Anthropic Skills API.
Fields:
id (str): Unique identifiercreated_at (str): ISO 8601 timestampdisplay_title (str, optional): Display titlelatest_version (str, optional): Latest version identifiersource (str): Source ("custom" or "anthropic")type (str): Object type (always "skill")updated_at (str): ISO 8601 timestampListSkillsResponseResponse from listing skills.
Fields:
data (List[Skill]): List of skillsnext_page (str, optional): Pagination token for the next pagehas_more (bool): Whether more skills are availableDeleteSkillResponseResponse from deleting a skill.
Fields:
id (str): The deleted skill IDtype (str): Deleted object type (always "skill_deleted")The Skills API implementation follows LiteLLM's standard patterns:
Type Definitions (litellm/types/llms/anthropic_skills.py)
Base Configuration (litellm/llms/base_llm/skills/transformation.py)
BaseSkillsAPIConfigProvider Implementation (litellm/llms/anthropic/skills/transformation.py)
AnthropicSkillsConfig - Anthropic-specific transformationsMain Handler (litellm/skills/main.py)
HTTP Handlers (litellm/llms/custom_httpx/llm_http_handler.py)
The Skills API is in beta. The beta header (skills-2025-10-02) is automatically added by the Anthropic provider configuration. You can customize it if needed:
skill = litellm.create_skill(
display_title="My Skill",
extra_headers={
"anthropic-beta": "skills-2025-10-02" # Or any other beta version
},
custom_llm_provider="anthropic"
)
The default beta version is configured in litellm.constants.ANTHROPIC_SKILLS_API_BETA_VERSION.
All Skills API functions follow LiteLLM's standard error handling:
import litellm
try:
skill = litellm.create_skill(
display_title="My Skill",
custom_llm_provider="anthropic"
)
except litellm.exceptions.AuthenticationError as e:
print(f"Authentication failed: {e}")
except litellm.exceptions.RateLimitError as e:
print(f"Rate limit exceeded: {e}")
except litellm.exceptions.APIError as e:
print(f"API error: {e}")
To add support for Skills API to a new provider:
BaseSkillsAPIConfigProviderConfigManager.get_provider_skills_api_config()For issues or questions: