Create agents on-the-fly without saving to workspace.
Basic Usage
1from inferencesh import inference23client = inference(api_key="inf_your_key")45agent = client.agent({6 "core_app": { "ref": "infsh/claude-sonnet-4@latest" },7 "system_prompt": "You are a helpful assistant."8})910response = agent.send_message("Hello!")11print(response.text)Configuration Options
1agent = client.agent({2 # Required - core_app with ref3 "core_app": {4 "ref": "infsh/claude-sonnet-4@latest",5 "setup": {...}, # One-time setup values (API keys, etc.)6 "input": {...} # Default input values7 },89 # Optional10 "system_prompt": "You are a helpful assistant.",11 "tools": [...], # Custom tools12 "skills": [...], # On-demand context (see Skills section)13 "internal_tools": {...}, # Built-in tool settings14 "output_schema": {...}, # JSON Schema for structured output (uses finish tool)15 "max_tool_iterations": 10, # Tool call limit16 "enable_autocomplete": True,1718 # Model parameters (shorthand for core_app.input)19 "temperature": 0.7,20 "max_tokens": 4096,21})Core Apps
| App | Description |
|---|---|
infsh/claude-sonnet-4 | Claude Sonnet 4 |
infsh/claude-haiku-35 | Claude 3.5 Haiku |
infsh/gpt-4o | GPT-4o |
infsh/gpt-4o-mini | GPT-4o Mini |
With Tools
1from inferencesh import tool, string23weather_tool = (4 tool("get_weather")5 .describe("Get current weather")6 .param("city", string("City name"))7 .handler(lambda args: f"Weather in {args['city']}: 72°F, Sunny")8 .build()9)1011agent = client.agent({12 "core_app": { "ref": "infsh/claude-sonnet-4@latest" },13 "system_prompt": "You help with weather info.",14 "tools": [weather_tool]15})1617response = agent.send_message("What's the weather in Paris?")Skills
Skills are reusable packages of context that agents can load on-demand via the skill_get tool. Instead of putting everything in the system prompt, define skills that the agent retrieves when needed.
1agent = client.agent({2 "core_app": { "ref": "infsh/claude-sonnet-4@latest" },3 "system_prompt": "You are a helpful code assistant.",4 "skills": [5 # Inline content6 {7 "name": "code-review",8 "description": "Guidelines for reviewing pull requests",9 "content": "# Code Review\n\nWhen reviewing code, check for:\n1. Security issues\n2. Performance..."10 },11 # URL-based (fetched and cached)12 {13 "name": "api-docs",14 "description": "API documentation",15 "url": "https://example.com/skills/api-docs.md"16 }17 ]18})The agent sees available skills in the skill_get tool description and loads full content only when relevant. See Internal Tools for more details.
Structured Output
Use output_schema to get typed JSON responses instead of free-form text. The agent uses the finish tool to return data matching your schema.
1agent = client.agent({2 "core_app": { "ref": "infsh/claude-sonnet-4@latest" },3 "system_prompt": "Extract structured data from text.",4 "output_schema": {5 "type": "object",6 "properties": {7 "summary": { "type": "string", "description": "Brief summary" },8 "sentiment": { "type": "string", "enum": ["positive", "negative", "neutral"] },9 "confidence": { "type": "number", "description": "Confidence score 0-1" }10 },11 "required": ["summary", "sentiment", "confidence"]12 },13 "internal_tools": { "finish": True }14})See Structured Output for the full guide — schema helpers, use cases, and tips.
Internal Tools
Enable built-in tools:
1agent = client.agent({2 "core_app": { "ref": "infsh/claude-sonnet-4@latest" },3 "internal_tools": {4 "web_search": True,5 "code_execution": True,6 "image_generation": {7 "enabled": True,8 "app_ref": "infsh/flux@latest"9 }10 }11})