Tool Call API
HTTP API for integrating anytool into your LLM applications
Recommended: This is the most flexible way to integrate anytool. Works with any LLM framework or custom application.
Quick Start
Make a simple HTTP POST request to generate and execute tools:
curl -X POST https://anytoolhq.com/api/tool \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "QR code generator",
"input": "https://example.com"
}'Authentication
Include your API key in the Authorization header:
Authorization: Bearer YOUR_API_KEY
Request Format
POST /api/tool
{
"prompt": "string", // Description of the tool you want
"input": "string", // Input data for the tool
"forceRegenerate": false // Optional: force new generation
}Response Format
Response
{
"output": "string", // Tool output (HTML, JSON, etc.)
"outputType": "string", // Type: "html", "json", "text", "image"
"contentType": "string", // MIME type
"cached": boolean, // Whether result was cached
"toolId": "string" // Unique tool identifier
}AI SDK Integration
Perfect for AI SDK with tool calling:
import { generateText } from 'ai'
import { openai } from '@ai-sdk/openai'
import { z } from 'zod'
const anytool = {
name: 'anytool',
description: 'Generate and execute any tool on demand',
parameters: z.object({
prompt: z.string(),
input: z.string()
}),
execute: async ({ prompt, input }) => {
const res = await fetch('https://anytoolhq.com/api/tool', {
method: 'POST',
headers: { 'Authorization': `Bearer ${ANYTOOL_KEY}` },
body: JSON.stringify({ prompt, input })
})
return res.json()
}
}
// Use in your LLM
await generateText({
model: openai('gpt-5-mini'),
tools: { anytool },
prompt: 'Generate a QR code for https://example.com'
})LangChain Integration
Works seamlessly with LangChain tools:
from langchain.tools import Tool
import requests
def anytool_call(prompt: str, input: str) -> str:
response = requests.post(
'https://anytoolhq.com/api/tool',
headers={'Authorization': f'Bearer {ANYTOOL_KEY}'},
json={'prompt': prompt, 'input': input}
)
return response.json()['output']
anytool = Tool(
name='anytool',
description='Generate and execute any tool on demand',
func=lambda prompt, input: anytool_call(prompt, input)
)Environment Variables
Securely inject API keys and environment variables:
- Add variables in Settings → Environment
- Access them in generated tools as
env.YOUR_KEY_NAME - Variables are encrypted at rest and injected at runtime
Rate Limits
- Free tier: 1,000 requests/month
- Pro tier: Unlimited requests
- Rate limiting: 100 requests/minute per API key
Error Handling
Handle errors gracefully in your application:
try {
const response = await fetch('https://anytoolhq.com/api/tool', {
method: 'POST',
headers: { 'Authorization': `Bearer ${ANYTOOL_KEY}` },
body: JSON.stringify({ prompt, input })
})
if (!response.ok) {
const error = await response.json()
throw new Error(error.message || 'Tool generation failed')
}
const result = await response.json()
return result.output
} catch (error) {
console.error('anytool error:', error.message)
return 'Tool generation failed'
}Best Practices
- Cache results: Tools are cached by default for performance
- Handle timeouts: Set reasonable timeout values (30s recommended)
- Validate inputs: Sanitize user inputs before sending to API
- Monitor usage: Track API calls to stay within limits
Next Steps
Ready to integrate? Check out:
- Quick Start Guide - Get up and running in minutes
- Security Guide - Best practices for API keys
- Writing Prompts - Tips for better tool generation