Developers building intelligent applications often need an LLM that can call external tools, stream results, and understand Arabic. LLM Resayil offers an OpenAI‑compatible API that supports function calling, tool use, streaming, vision, and thinking models—all billed per use in USD via Stripe or PayPal. This guide walks you through every step, from defining tools to scaling your production workloads.
Tool Use Patterns with LLM Resayil
Developers building intelligent applications often need an LLM that can call external tools, stream results, and understand Arabic. LLM Resayil offers an OpenAI‑compatible API that supports function calling, tool use, streaming, vision, and thinking models—all billed per use in USD via Stripe or PayPal. This guide walks you through every step, from defining tools to scaling your production workloads.
Quick Comparison
| Feature | LLM Resayil | OpenAI (GPT‑4) |
|---|---|---|
| OpenAI compatibility | ✅ | ✅ |
| Anthropic compatibility | ✅ | ❌ |
| Arabic language support | ✅ | ✅ |
| Vision model access | ✅ (e.g., qwen3-vl:235b) | ✅ |
| Thinking models | ✅ (e.g., deepseek-v4-pro) | ✅ |
| Streaming | ✅ | ✅ |
| Function calling / tool use | ✅ | ✅ |
| Pay‑per‑use pricing | ✅ (USD) | ✅ (USD) |
| Payment methods | Stripe, PayPal | Stripe, credit cards |
| Hosting location | USA | Global (Microsoft Azure) |
What LLM Resayil Offers
LLM Resayil’s API is OpenAI and Anthropic compatible, meaning you can reuse existing SDKs and code patterns. The platform ships with 39 models ranging from chat‑optimized to vision‑enabled and high‑capacity thinking models. All endpoints are hosted in the USA, and you pay only for the tokens you consume, making it ideal for bursty workloads.
Key capabilities for tool‑driven applications:
- Tool use and function calling let the model decide when to invoke a predefined external service.
- Streaming returns partial results instantly, perfect for UI‑rich experiences.
- Vision models can analyze images and then trigger downstream tools.
- Thinking models (e.g.,
deepseek-v4-pro) excel at multi‑step reasoning before a tool call. - Arabic language support ensures prompts, tool definitions, and responses work flawlessly for Arabic‑speaking users.
What OpenAI (GPT‑4) Offers
OpenAI provides a mature ecosystem with extensive documentation, a large community, and a suite of plugins for tool integration. GPT‑4 supports function calling, streaming, and multi‑language capabilities, and it is priced per token in USD. While OpenAI’s ecosystem is robust, it does not include native Anthropic compatibility or the same breadth of specialized vision and thinking models that Resayil bundles.
Why LLM Resayil Wins for Tool‑Use Patterns
If your application needs Arabic‑first experiences, vision‑augmented reasoning, or you want to mix OpenAI‑compatible and Anthropic‑compatible calls without switching providers, Resayil is the clear choice. Its pay‑per‑use model removes the overhead of fixed monthly fees, and the integrated Stripe and PayPal options simplify billing for global teams.
What You Get by Using LLM Resayil
- Full OpenAI‑compatible endpoint set (
/v1/chat/completions,/v1/messages, etc.) - Tool use and function calling built‑in, no extra plugin required
- Streaming responses for real‑time UI updates
- Vision‑enabled models (
qwen3-vl:235b,glm-5) that can feed image data into tools - Thinking models for complex, multi‑step workflows
- Arabic language support across all features
- Transparent pay‑per‑use credits displayed via
/v1/pricing - Easy integration with n8n, LangChain, LiteLLM, and the standard OpenAI/Anthropic SDKs
Understanding Tool Use in LLM Resayil {#understanding-tool-use}
Tool use in LLM Resayil refers to the model’s ability to decide, during a conversation, that it needs to call an external function or service you have defined. This is powered by the function calling and tool use features listed in the product facts. When the model detects that a user request requires external data—such as fetching a weather forecast, querying a database, or processing an image—it returns a structured tool_calls object.
Because the API is OpenAI compatible, you can define tools using the same JSON schema you would with OpenAI’s functions parameter. The same applies to Anthropic compatibility, where you can use the tools field in Claude‑style calls. The model will then emit a tool_call response that your client code can parse and execute.
The workflow looks like this:
- Send a chat request with a list of tool definitions.
- Model evaluates the user message and decides whether a tool is needed.
- Model returns a
tool_callsobject describing the chosen tool and its arguments. - Your application executes the tool (e.g., an HTTP request, database query).
- You send the tool result back to the model as a new message, allowing it to continue the conversation with the fresh data.
This loop enables sophisticated, stateful interactions while keeping the LLM stateless.
Setting Up Tool Use with the API Endpoints {#setup-tool-use}
The two endpoints you’ll interact with most are /v1/chat/completions (for chat‑style exchanges) and /v1/messages (for generic message handling and token counting). Below are step‑by‑step examples in Python (using the OpenAI SDK) and cURL.
Python Example
import os
import openai
# Use your Resayil API key
openai.api_key = os.getenv("RESAYIL_API_KEY")
openai.base_url = "https://llm.resayil.io/v1"
tools = [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Retrieve current weather for a city",
"parameters": {
"type": "object",
"properties": {
"city": {"type": "string", "description": "Name of the city"}
},
"required": ["city"]
}
}
}
]
response = openai.ChatCompletion.create(
model="deepseek-v4-flash", # a chat‑optimized model from the catalog
messages=[{"role": "user", "content": "ما هو الطقس الآن في دبي؟"}],
tools=tools,
tool_choice="auto",
stream=False
)
print(response)
cURL Example (Streaming Enabled)
curl https://llm.resayil.io/v1/chat/completions \
-H "Authorization: Bearer $RESAYIL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4-flash",
"messages": [{"role": "user", "content": "ما هو الطقس الآن في الرياض؟"}],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Retrieve current weather for a city",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"]
}
}
}],
"tool_choice": "auto",
"stream": true
}' \
--no-buffer | while IFS= read -r line; do echo "$line"; done
Key points:
- The
toolsfield follows the OpenAI schema; you can also use the Anthropic‑style schema if you prefer that SDK. - Set
tool_choicetoautoso the model decides when to invoke a tool. - For streaming, add
"stream": trueand handle each JSON line as it arrives. - Use
/v1/messages/count_tokensif you need to know token usage before sending the request (useful for budgeting Arabic prompts).
Common Tool Use Patterns: Streaming, Thinking Models, and Vision {#common-patterns}
1. Streaming Tool Calls
When the model decides to call a tool, the response can be streamed back to the client. This reduces latency for UI components that display partial results (e.g., a loading spinner that updates once the tool call is identified). Implement a streaming loop as shown in the cURL example, or in Python by passing stream=True and iterating over response.
2. Multi‑Step Reasoning with Thinking Models
Thinking models such as deepseek-v4-pro, qwen3.5:397b, or kimi-k2-thinking excel at planning before a tool call. A typical pattern:
- Prompt the model to plan the steps required to answer a complex query.
- The model outputs a structured plan (often as a JSON list).
- Your code iterates through the plan, invoking tools as needed.
- Feed each tool’s result back to the model for the next step.
This approach reduces the number of round‑trips and keeps token usage efficient.
3. Vision‑Enhanced Tool Use
Vision models like qwen3-vl:235b or glm-5 can analyze images and then trigger a tool. Example workflow:
- User uploads a receipt image.
- You send the image to the vision model via
/v1/chat/completionswith amultimodalflag (supported by the model). - The model extracts text, decides it needs to call a
parse_receiptfunction, and returns atool_callspayload. - Your backend runs the parser and returns the structured receipt data to the model for final summarization.
By chaining vision and tool use, you can build end‑to‑end OCR, translation, or content‑moderation pipelines without managing separate OCR services.
Integrating Tool Use with n8n, LangChain, and LiteLLM {#integrations}
n8n Workflow
- HTTP Request node – call
/v1/chat/completionswith your tool definitions. - Function node – parse the
tool_callsresponse and route to the appropriate downstream node (e.g., a database query or external API). - Set node – add the tool result back to the message payload.
- Loop – feed the updated payload into another HTTP Request node to continue the conversation.
n8n’s visual interface makes it easy to visualize the tool‑call loop and add retries or error handling.
LangChain Integration
from langchain.llms import OpenAI
from langchain.tools import StructuredTool
from langchain.agents import initialize_agent, AgentType
# Resayil endpoint configuration
llm = OpenAI( # OpenAI‑compatible wrapper
api_key=os.getenv("RESAYIL_API_KEY"),
base_url="https://llm.resayil.io/v1",
model="deepseek-v4-flash",
streaming=True,
)
def get_weather(city: str) -> str:
# Your custom implementation
return f"Current weather in {city} is 27°C, clear skies."
weather_tool = StructuredTool.from_function(func=get_weather, name="get_weather")
agent = initialize_agent(
tools=[weather_tool],
llm=llm,
agent=AgentType.OPENAI_FUNCTIONS,
verbose=True,
)
response = agent.run("ما هو الطقس الآن في القاهرة؟")
print(response)
LangChain automatically translates the tool definition into the OpenAI‑compatible schema, handles the tool_calls loop, and streams partial results.
Ready to try Resayil LLM API?
Start FreeLiteLLM Wrapper
LiteLLM abstracts multiple providers under a single interface. To use Resayil:
import litellm
litellm.api_key = os.getenv("RESAYIL_API_KEY")
litellm.api_base = "https://llm.resayil.io/v1"
response = litellm.completion(
model="deepseek-v4-flash",
messages=[{"role": "user", "content": "ما هو معدل الصرف اليوم؟"}],
tools=[{"type": "function", "function": {"name": "get_exchange_rate", "description": "Fetch USD to SAR rate", "parameters": {"type": "object", "properties": {}, "required": []}}}],
stream=False,
)
print(response)
All three integrations respect the pay‑per‑use pricing model, so you only pay for the tokens consumed by each tool‑driven interaction.
Best Practices for Arabic Language Tool Use {#arabic-best-practices}
- Write tool descriptions in Arabic – The model understands multilingual schemas, so providing Arabic
descriptionfields improves relevance. - Normalize Unicode – Ensure incoming Arabic text is NFC‑normalized to avoid token‑count discrepancies.
- Use
/v1/messages/count_tokensbefore large prompts to estimate cost, especially when combining Arabic with image data for vision models. - Design tool arguments with clear naming – Arabic developers often prefer camelCase or snake_case; both work, but stay consistent to simplify parsing.
- Handle right‑to‑left rendering – When streaming responses back to a UI, make sure the client respects RTL layout to keep the user experience smooth.
- Test with both OpenAI and Anthropic SDKs – Because Resayil is compatible with both, verify that your tool schema works across the two client libraries.
Following these practices ensures low latency, accurate token accounting, and a seamless Arabic user experience.
Pricing and Scalability Considerations for Tool Use {#pricing-scalability}
LLM Resayil operates on a pay‑per‑use credits model. Each API call—including those that involve tool calls—consumes credits based on the number of input and output tokens. You can view exact rates via the /v1/pricing endpoint and purchase additional credits through /v1/pricing/topups.
All billing is in USD, and you can pay via Stripe or PayPal. Because there is no fixed monthly fee, you can scale from a few daily tool calls to thousands without renegotiating contracts. Monitoring your usage through the /v1/messages/count_tokens endpoint helps you stay within budget and predict costs as your application grows.
FAQ
Q: How do I define a tool for LLM Resayil using the OpenAI‑compatible API?
A: Include a tools array in your /v1/chat/completions request. Each entry follows the OpenAI function schema with type: "function" and a nested function object that specifies name, description, and parameters. Set tool_choice to auto so the model decides when to call the tool.
Q: Does LLM Resayil support streaming when using tool calls?
A: Yes. By adding "stream": true to the request payload, the API returns a chunked response. Each chunk may contain a tool_calls object, allowing your client to react instantly to the model’s decision to invoke a tool.
Q: Can I use tool use with Arabic language prompts?
A: Absolutely. LLM Resayil offers Arabic language support, so both the user prompt and the tool definitions can be written in Arabic. The model will parse the Arabic text, decide on tool usage, and return responses in Arabic.
Q: What is the difference between function calling and tool use in LLM Resayil?
A: Function calling is a specific implementation of tool use that follows the OpenAI function schema. Tool use is the broader concept that includes any external operation the model may trigger—whether defined as a function, a custom tool, or an Anthropic‑style tool. Both are supported and interchangeable in the API.
Q: How does pay‑per‑use pricing affect the cost of tool use patterns?
A: Every token processed—whether in the original user message, the model’s reasoning, or the tool’s output—consumes credits. There are no fixed fees; you only pay for the tokens actually used. You can review exact rates via /v1/pricing and track consumption with /v1/messages/count_tokens.
Call to Action
Ready to build Arabic‑first, tool‑driven AI experiences? Register now, explore the pricing page, and dive into the full documentation to start integrating LLM Resayil today.
This article was written for developers looking to harness the full power of tool use, streaming, vision, and Arabic language support with LLM Resayil.