| Feature | LLM Resayil | OpenAI | |---|---|---| | API Compatibility | OpenAI‑compatible and Anthropic‑compatible | OpenAI‑compatible | | Arabic Language Support | ✅ | ❌ (requires separate model) | | Function Calling / Tool Use | ✅ (function calling, tool use) | ✅ | | Streaming Responses | ✅ | ✅ | | Pay‑per‑Use Billing | ✅ (credits) | ✅ | | Hosting Location | USA | Global | | Integrations | n8n, LangChain, LiteLLM, OpenAI SDK, Anthropic SDK, Python, JavaScript, cURL | OpenAI SDK, Python, JavaScript, cURL |
Function Calling with LLM Resayil OpenAI‑Compatible API
Quick Overview
| Feature | LLM Resayil | OpenAI | |---|---|---| | API Compatibility | OpenAI‑compatible and Anthropic‑compatible | OpenAI‑compatible | | Arabic Language Support | ✅ | ❌ (requires separate model) | | Function Calling / Tool Use | ✅ (function calling, tool use) | ✅ | | Streaming Responses | ✅ | ✅ | | Pay‑per‑Use Billing | ✅ (credits) | ✅ | | Hosting Location | USA | Global | | Integrations | n8n, LangChain, LiteLLM, OpenAI SDK, Anthropic SDK, Python, JavaScript, cURL | OpenAI SDK, Python, JavaScript, cURL |
What LLM Resayil Offers
LLM Resayil provides an OpenAI‑compatible endpoint (/v1/chat/completions) that supports function calling, tool use, streaming, and Arabic language handling. The platform runs in the USA, charges in USD via Stripe or PayPal, and follows a pay‑per‑use credits model.
What OpenAI Offers
OpenAI’s API also supports function calling, streaming, and a wide range of models. It is hosted globally and billed in several currencies. While OpenAI has a large model catalog, it does not include native Arabic language support in every model.
Why LLM Resayil Wins for Function Calling
For developers building chatbots or AI agents that must understand Arabic and integrate external tools, LLM Resayil combines OpenAI compatibility, Arabic support, and pay‑per‑use credits in a single US‑hosted service. This reduces the need for multiple providers and simplifies billing.
Concrete Benefits You Get
- Zero‑code language switch – Arabic prompts work out of the box.
- Predictable costs – Only pay for the tokens you consume.
- Full tool ecosystem – Use n8n, LangChain, or LiteLLM directly with the same endpoint.
- Fast, reliable hosting – US data centers ensure low latency for North American users.
- Rich model catalog – Choose from 39 models, including vision and thinking models, to match your workload.
Introduction to Function Calling with LLM Resayil (≈200 words)
Function calling lets a language model invoke external code during a conversation. Instead of returning a plain text answer, the model can output a structured request that tells your application which function to run, what arguments to pass, and why. This enables powerful AI agents that can look up live data, trigger workflows, or perform calculations on the fly.
LLM Resayil’s API is OpenAI‑compatible, so the request format follows the familiar tools parameter pattern. The platform also supports the tool use feature, which is Anthropic’s equivalent of function calling, giving you flexibility regardless of which compatibility mode you choose. Because the service is built with Arabic language support, you can build multilingual bots that switch seamlessly between English and Arabic while still leveraging external tools.
Setting Up the Environment for Function Calling (≈300 words)
- Create an API key on the Resayil portal (https://llm.resayil.io).
- Endpoint – All calls go to
https://llm.resayil.io/v1/chat/completions. - Authentication – Send the key in the
Authorization: Bearer <YOUR_KEY>header. - Supported SDKs – You can use the official OpenAI SDK, Anthropic SDK, plain cURL, or any HTTP client in Python or JavaScript. The same key works across all integrations.
- Billing – The service uses a pay‑per‑use credits model billed in USD via Stripe or PayPal. Credits are deducted based on the total tokens processed (prompt + completion, including any function‑call payloads).
- Health Check – Before integration, hit
/v1/healthto confirm the service is up.
curl -s https://llm.resayil.io/v1/health
With the environment ready, you can start defining functions and sending chat requests.
Defining Functions and Tool Use in Requests (≈350 words)
In Resayil, a function is described using a JSON schema inside the tools array. The schema must contain:
type: "function"function.namefunction.descriptionfunction.parameters(a JSON‑Schema object describing required fields).
Example schema for a weather lookup:
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "Retrieve current weather for a city",
"parameters": {
"type": "object",
"properties": {
"city": {"type": "string", "description": "Name of the city"},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
},
"required": ["city"]
}
}
}
When you send a chat request, include the tools field:
{
"model": "deepseek-v4-flash",
"messages": [{"role": "user", "content": "What’s the weather in Dubai?"}],
"tools": [/* schema above */],
"tool_choice": "auto"
}
The model will either answer directly or return a function call object:
{"role": "assistant", "content": null, "tool_calls": [{"id": "call_1", "type": "function", "function": {"name": "get_current_weather", "arguments": "{\"city\":\"Dubai\",\"unit\":\"celsius\"}"}}]}
Function calling vs. tool use – In the OpenAI‑compatible endpoint you use tools. The Anthropic‑compatible /v1/messages endpoint uses the same concept under the name tool use. Both produce the same structured output, letting you pick the API style you prefer.
Streaming – If you set stream: true, the response arrives token‑by‑token, and the function‑call payload is streamed as a delta, enabling real‑time processing.
Ready to try Resayil LLM API?
Start FreeHandling Function Responses and Executing External Actions (≈300 words)
- Detect the function call – After the API returns a
tool_callsarray, extract thenameandarguments. - Execute locally – Run your own code (e.g., call a weather API) using the arguments.
- Send the result back – Create a new message with
role: "tool", include thetool_call_id, and provide the function’s output ascontent. - Continue the conversation – Append the tool message to the chat history and make another
/v1/chat/completionsrequest. The model now has the data it needs to finish the answer.
Python example (OpenAI SDK)
import os, json
from openai import OpenAI
client = OpenAI(api_key=os.getenv("RESAYIL_API_KEY"), base_url="https://llm.resayil.io/v1")
# Step 1: Ask the model
response = client.chat.completions.create(
model="deepseek-v4-flash",
messages=[{"role": "user", "content": "What’s the weather in Riyadh?"}],
tools=[YOUR_TOOL_SCHEMA],
tool_choice="auto",
stream=False,
)
tool_call = response.choices[0].message.tool_calls[0]
args = json.loads(tool_call.function.arguments)
# Step 2: Execute external function (mocked here)
weather = f"28°C, clear skies in {args['city']}"
# Step 3: Send result back
follow_up = client.chat.completions.create(
model="deepseek-v4-flash",
messages=[
{"role": "user", "content": "What’s the weather in Riyadh?"},
{"role": "assistant", "content": None, "tool_calls": [tool_call]},
{"role": "tool", "tool_call_id": tool_call.id, "content": weather},
],
stream=False,
)
print(follow_up.choices[0].message.content)
JavaScript example (OpenAI SDK)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.RESAYIL_API_KEY,
baseURL: "https://llm.resayil.io/v1",
});
// 1️⃣ Ask the model
const first = await client.chat.completions.create({
model: "deepseek-v4-flash",
messages: [{ role: "user", content: "What’s the weather in Cairo?" }],
tools: [YOUR_TOOL_SCHEMA],
tool_choice: "auto",
});
const toolCall = first.choices[0].message.tool_calls[0];
const args = JSON.parse(toolCall.function.arguments);
// 2️⃣ Run your function (mocked)
const weather = `${args.city} is 30°C and sunny`;
// 3️⃣ Send back the tool result
const final = await client.chat.completions.create({
model: "deepseek-v4-flash",
messages: [
{ role: "user", content: "What’s the weather in Cairo?" },
{ role: "assistant", content: null, tool_calls: [toolCall] },
{ role: "tool", tool_call_id: toolCall.id, content: weather },
],
});
console.log(final.choices[0].message.content);
These snippets show the full round‑trip: request → function call → external execution → result → final answer.
Advanced Use Cases: Multi‑Turn Conversations and Chaining (≈250 words)
Complex agents often need multiple sequential tool calls. For example, a travel‑assistant might first fetch flight options, then call a hotel‑search tool, and finally calculate total cost. With Resayil you can:
- Chain tools – After each tool response, send a new chat request that includes the previous tool messages. The model can decide to call another tool based on the new context.
- Leverage n8n or LangChain – Use the n8n integration to orchestrate multi‑step workflows without writing custom orchestration code. LangChain can wrap the Resayil client, handling tool‑call parsing automatically.
- Streaming for real‑time feedback – Enable
stream: trueon every request. The client receives partial tokens and tool‑call deltas instantly, allowing UI components to show “Thinking…” while the model decides the next action. - Thinking models – For heavy reasoning, pick a “thinking” model such as
deepseek-v4-proorkimi-k2-thinking. These models excel at planning multi‑step chains before emitting the first tool call. By combining these patterns, you can build AI agents that act like human assistants, performing complex, multi‑step tasks with minimal latency.
Troubleshooting and Best Practices (≈250 words)
| Issue | Recommendation |
|---|---|
| Invalid function schema | Validate JSON‑Schema with a lint tool. Ensure name, description, and parameters are present and that required fields are listed. |
| Unexpected null response | Check that tool_choice is set to auto or the specific tool name. |
| Token limit exceeded | Use the /v1/messages/count_tokens endpoint to estimate token usage before sending large payloads. |
| Slow streaming | Verify network latency to the US data center and consider using a “thinking” model with larger context windows to reduce round‑trips. |
| Billing surprises | Monitor credit consumption in the portal. Remember that pay‑per‑use credits are deducted for every token, including function‑call payloads. |
General best practices:
- Keep function schemas small and focused; unnecessary parameters increase token count.
- Cache frequent external API results when possible to lower repeated token usage.
- Use the
/v1/healthendpoint to confirm service availability before critical calls. - Log the
tool_call_idso you can reliably match tool responses to the originating request.
Code Example: Calling a Vision Model with Function Calling (Python)
import os, json
from openai import OpenAI
client = OpenAI(api_key=os.getenv("RESAYIL_API_KEY"), base_url="https://llm.resayil.io/v1")
# Define a simple image‑analysis function
vision_tool = {
"type": "function",
"function": {
"name": "describe_image",
"description": "Return a textual description of the supplied image URL",
"parameters": {
"type": "object",
"properties": {
"url": {"type": "string", "description": "Public URL of the image"}
},
"required": ["url"]
}
}
}
response = client.chat.completions.create(
model="qwen3-vl:235b-instruct", # vision‑capable model from the catalog
messages=[{"role": "user", "content": "What is shown in this picture? https://example.com/pic.jpg"}],
tools=[vision_tool],
tool_choice="auto",
stream=False,
)
tool_call = response.choices[0].message.tool_calls[0]
args = json.loads(tool_call.function.arguments)
# Mock external image analysis (could call a real service)
description = "A bustling market street in Marrakech with colorful stalls."
# Send result back
final = client.chat.completions.create(
model="qwen3-vl:235b-instruct",
messages=[
{"role": "user", "content": "What is shown in this picture? https://example.com/pic.jpg"},
{"role": "assistant", "content": None, "tool_calls": [tool_call]},
{"role": "tool", "tool_call_id": tool_call.id, "content": description},
],
stream=False,
)
print(final.choices[0].message.content)
This example demonstrates how a vision‑enabled model can request a helper function, receive the result, and produce a final answer—all through the OpenAI‑compatible Resayil API.
Frequently Asked Questions
Q: How do I define a function in the LLM Resayil API request?
A: Use the tools parameter with a JSON schema that includes the function’s name, description, and parameters. The request follows the OpenAI‑compatible function calling specification, so the schema format matches OpenAI’s documentation.
Q: Does LLM Resayil support streaming with function calling?
A: Yes. Streaming is a listed feature. When you set stream: true, the API streams function‑call deltas, enabling real‑time processing of tool invocations.
Q: Can I use function calling with the Anthropic‑compatible endpoint?
A: LLM Resayil offers both OpenAI‑compatible and Anthropic‑compatible APIs. The /v1/messages endpoint supports tool use (Anthropic’s equivalent of function calling), so you can invoke functions via that route as well.
Q: What SDKs can I use to implement function calling with LLM Resayil?
A: The platform integrates with the OpenAI SDK, Anthropic SDK, Python, JavaScript, cURL, n8n, LangChain, and LiteLLM. For the OpenAI‑compatible /v1/chat/completions endpoint, the OpenAI SDK is the most straightforward choice.
Q: How is billing handled for function calling requests? A: LLM Resayil uses a pay‑per‑use credits model. Billing is in USD and processed through Stripe or PayPal. Each API call, including those that involve function calls, consumes credits based on total token usage.
Take the Next Step
Ready to add powerful tool integration to your AI agents? Sign up at the Resayil portal, grab an API key, and start experimenting with function calling today. Check our pricing page for credit details, and dive into the documentation for full API references.