હોમ / માર્ગદર્શિકાઓ / function calling સાથે મફત LLM API

function calling સાથે મફત LLM API

Function calling, અથવા tool calling, LLM ને તમારા કોડને function ચલાવવા કહેવા દે છે. Agents, લાઇવ ડેટાવાળા chat bots અને structured extraction બધા તેનો ઉપયોગ કરે છે. FreeLLMAPI catalog માં tool calling સાથે 190 મફત મોડેલ ઑફર છે. તમે OpenAI-શૈલીના tools મોકલો છો, અને ગેટવે દરેક પ્રદાતા માટે તેમનું રૂપાંતર કરે છે.

કોડ, મૉડેલ નામ અને લાઇવ કૅટલૉગ લેબલ અંગ્રેજીમાં બતાવવામાં આવે છે.

FreeLLMAPI દ્વારા tool calling કેવી રીતે કામ કરે છે

  1. તમે messages અને tools ની યાદી મોકલો છો. દરેક tool માં નામ, વર્ણન અને તેના parameters માટે JSON Schema હોય છે.
  2. મોડેલ tool_calls અને finish_reason: "tool_calls" સાથે જવાબ આપે છે. તે પોતે કંઈ ચલાવતું નથી.
  3. તમારો કોડ function ચલાવે છે, અને પરિણામ role: "tool" સાથે message તરીકે ઉમેરે છે.
  4. તમે વાતચીત ફરીથી મોકલો છો. મોડેલ પરિણામ વાપરીને અંતિમ જવાબ લખે છે.

Groq, Cerebras, Mistral, OpenRouter અને Cloudflare જેવા OpenAI સાથે સુસંગત પ્રદાતા વિનંતી જેમ છે તેમ મેળવે છે. Gemini માટે, FreeLLMAPI tools ને Google’s functionDeclarations ફોર્મેટમાં રૂપાંતરિત કરે છે અને જવાબ પાછો રૂપાંતરિત કરે છે. દરેક પ્રદાતા માટે તમારો કોડ એક જ છે.

કેટલાક મોડેલ tool call ને સાદા લખાણ તરીકે લખે છે, વાસ્તવિક tool call તરીકે નહીં. FreeLLMAPI આને શોધે છે અને તેમને વાસ્તવિક tool_calls માં બદલે છે.

આજે tool calling સાથે મફત મોડેલ

કોષ્ટક tool calling સાથેના સૌથી મજબૂત મફત મોડેલ બતાવે છે. ડેટા લાઇવ catalog માંથી આવે છે. Agents માટે, context નું કદ પણ તપાસો, કારણ કે tool ની વ્યાખ્યાઓ અને પરિણામો ઘણા tokens વાપરે છે.

tool calling સાથે મફત મોડેલ, સૌથી મજબૂત પહેલા
મૉડેલમફત ઉપલબ્ધસંદર્ભમફત મર્યાદા (શ્રેષ્ઠ ઑફર)સાધનોવિઝન
GLM 5.3UnoRouter1M1 વિનંતી/મિનિટ
1 req/min per model
હાના
Qwen3.8 MaxACLIDE-€20/month shared internal usage credits · no cardહાના
GLM 5.3 FlashNVIDIA NIM, UnoRouter1M40 વિનંતી/મિનિટ
40 RPM
હાહા
Gemini 3.8 FlashGoogle AI Studio1MRecurring provider quotaહાહા
Gemini Flash (latest alias)Google AI Studio-10 વિનંતી/મિનિટ
20 વિનંતી/દિવસ
250,000 ટોકન/મિનિટ
~3M
હાહા
Qwen3.8 Flash NextAMD Radeon Cloud262KRecurring daily account allowanceહાના
Qwen3.8 FlashElectronHub1M$0.25/week shared recurring creditહાહા
Gemini 3.7 FlashGoogle AI Studio1M10 વિનંતી/મિનિટ
20 વિનંતી/દિવસ
250,000 ટોકન/મિનિટ
~3M
હાહા
GPT-5.6 LunaElectronHub1M$0.25/week shared recurring creditહાહા
Dots3 Note PreviewKilo Gateway, OpenRouter512K20 વિનંતી/મિનિટ
50 વિનંતી/દિવસ
50 req/day account-wide (1,000 after a $10 purchase)
હાહા
DeepSeek V4 FlashAMD Radeon Cloud, BazaarLink, ElectronHub1M10 વિનંતી/મિનિટ
50 વિનંતી/દિવસ
Shared rate limit
હાના
Qwen3.8 27BElectronHub, Groq, OVH AI Endpoints262K30 વિનંતી/મિનિટ
250 વિનંતી/દિવસ
70,000 ટોકન/મિનિટ
~6M
હાહા
Gemini 3.6 FlashGoogle AI Studio1M10 વિનંતી/મિનિટ
20 વિનંતી/દિવસ
250,000 ટોકન/મિનિટ
~3M
હાહા
Qwen 3.8 27BCloudflare Workers AI262KShared 10k neurons/dayહાહા
Gemini 3.5 FlashGoogle AI Studio1M10 વિનંતી/મિનિટ
20 વિનંતી/દિવસ
250,000 ટોકન/મિનિટ
~3M
હાહા

મેળ ખાતા 146 મફત મૉડેલમાંથી 15 બતાવ્યા. બધા મૉડેલ જુઓ.

FreeLLMAPI કૅટલૉગનો લાઇવ ડેટા (સંસ્કરણ 2026.11.19, તપાસ્યું 2026-11-19). મફત મર્યાદાઓ વારંવાર બદલાય છે. કૅટલૉગ દરરોજ તપાસવામાં આવે છે.

પગલું 1: FreeLLMAPI ઇન્સ્ટોલ કરો અને કી ઉમેરો

FreeLLMAPI ઓપન સોર્સ છે. તે Docker માં તમારા કમ્પ્યુટર પર ચાલે છે. તમારી પ્રદાતા કી તમારા કમ્પ્યુટર પર જ રહે છે.

ઇન્સ્ટોલ કરો (macOS અથવા Linux)

curl -fsSL https://freellmapi.co/install.sh | bash

http://localhost:3001 પર ડૅશબોર્ડ ખોલો. Keys પેજ પર ત્રણ કે વધુ પ્રદાતાઓની કી ઉમેરો. tool loop એક કાર્ય માટે ઘણી વિનંતી મોકલે છે, તેથી વધુ કી વધુ જગ્યા આપે છે. એ જ પેજ પરથી તમારી યુનિફાઇડ કી કૉપી કરો.

પગલું 2: સંપૂર્ણ tool loop ચલાવો

curl: પહેલી વિનંતી

curl http://localhost:3001/v1/chat/completions \
  -H "Authorization: Bearer <unified-key>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "auto",
    "messages": [{"role": "user", "content": "What is the weather in Karachi?"}],
    "tools": [{
      "type": "function",
      "function": {
        "name": "get_weather",
        "description": "Get the current weather for a city.",
        "parameters": {
          "type": "object",
          "properties": {"city": {"type": "string"}},
          "required": ["city"]
        }
      }
    }]
  }'

Python: મોડેલ અંતિમ જવાબ આપે ત્યાં સુધી loop કરો

import json
from openai import OpenAI

client = OpenAI(base_url="http://localhost:3001/v1", api_key="<unified-key>")

def get_weather(city: str) -> dict:
    return {"city": city, "temp_c": 32, "condition": "sunny"}  # call a real API here

FUNCS = {"get_weather": get_weather}
tools = [{
    "type": "function",
    "function": {
        "name": "get_weather",
        "description": "Get the current weather for a city.",
        "parameters": {
            "type": "object",
            "properties": {"city": {"type": "string"}},
            "required": ["city"],
        },
    },
}]
messages = [{"role": "user", "content": "What is the weather in Karachi and Lahore?"}]

for _ in range(5):  # stop after 5 rounds
    msg = client.chat.completions.create(model="auto", messages=messages, tools=tools).choices[0].message
    if not msg.tool_calls:
        print(msg.content)
        break
    messages.append(msg)
    for call in msg.tool_calls:
        try:
            args = json.loads(call.function.arguments or "{}")
            result = FUNCS[call.function.name](**args)
        except Exception as exc:  # bad JSON, unknown tool or wrong arguments
            result = {"error": str(exc)}
        messages.append({"role": "tool", "tool_call_id": call.id, "content": json.dumps(result)})

Tool calling stream=True સાથે પણ કામ કરે છે. તમને delta.tool_calls chunks મળે છે, પછી finish_reason: "tool_calls" સાથે અંતિમ chunk. JSON parse કરતા પહેલાં argument chunks જોડો.

structured ડેટા મેળવવા tool વાપરો

Tool calling નિશ્ચિત આકારમાં ડેટા મેળવવાની સારી રીત પણ છે. એક tool વ્યાખ્યાયિત કરો જેના parameters તમે ઇચ્છો તે ફીલ્ડ હોય. tool_choice ને "required" પર સેટ કરો, જેથી મોડેલે tool કૉલ કરવો જ પડે. પછી arguments વાંચો. તમારે કોઈ function ચલાવવાની જરૂર નથી.

Python: જરૂરી tool call સાથે ફીલ્ડ કાઢો

import json
from openai import OpenAI

client = OpenAI(base_url="http://localhost:3001/v1", api_key="<unified-key>")
schema = {
    "type": "function",
    "function": {
        "name": "save_contact",
        "description": "Save one contact found in the text.",
        "parameters": {
            "type": "object",
            "properties": {"name": {"type": "string"}, "email": {"type": "string"}},
            "required": ["name", "email"],
        },
    },
}
resp = client.chat.completions.create(
    model="auto",
    messages=[{"role": "user", "content": "Reach Sara Khan at [email protected]."}],
    tools=[schema],
    tool_choice="required",
)
print(json.loads(resp.choices[0].message.tool_calls[0].function.arguments))

તમારા પોતાના કોડ વડે arguments ચકાસો. મોડેલ જરૂરી ફીલ્ડ છોડી શકે છે અથવા ખોટો પ્રકાર મોકલી શકે છે. ચકાસણી નિષ્ફળ જાય, તો ભૂલ પાછી મોકલો અને ફરીથી પૂછો.

સલામતી: ચુકવણી, ઇમેઇલ અથવા ફાઇલ કાઢી નાખવા જેવા side effects ધરાવતા tool calls ચકાસણી વિના ચલાવો નહીં. પહેલા વપરાશકર્તાને આ ક્રિયાઓની પુષ્ટિ કરવા કહો.

સામાન્ય ભૂલો

  • Arguments સ્ટ્રિંગ છે: function.arguments એ JSON સ્ટ્રિંગ છે. તેને parse કરો, અને ભૂલો પકડો. નાના મોડેલ ક્યારેક માન્ય ન હોય તેવું JSON મોકલે છે.
  • ids મેળવો: દરેક tool message ને તેના call નો tool_call_id જોઈએ. tool messages પહેલાં tool_calls વાળો assistant message ઉમેરો.
  • એક સાથે ઘણા calls: મોડેલ એક જવાબમાં એક કરતાં વધુ tool call પાછા આપી શકે છે. તે બધા ચલાવો, પછી બધા પરિણામો મોકલો.
  • Token ખર્ચ: દરેક tool ની વ્યાખ્યા દરેક વિનંતી સાથે મોકલાય છે. વીસ મોટા tools હજારો tokens વાપરી શકે છે અને નીચી tokens-per-minute મર્યાદા ઝડપથી પહોંચી શકે છે. કાર્યને જરૂરી tools જ મોકલો.
  • સ્પષ્ટ વર્ણન: મોડેલ તેના નામ અને વર્ણન પરથી tool પસંદ કરે છે. એક ટૂંકું વાક્ય લખો જે કહે કે tool શું કરે છે અને ક્યારે વાપરવું.
  • loop રોકો: rounds ની મહત્તમ સંખ્યા સેટ કરો. નબળું મોડેલ એ જ tool વારંવાર કૉલ કરી શકે છે.
  • Tools વગરના મોડેલ: કેટલાક મફત પ્રદાતા tools સપોર્ટ કરતા નથી. ઉદાહરણ તરીકે, AI Horde tools કાઢી નાખે છે અને સાદા chat તરીકે જવાબ આપે છે.
કાર્ય દરમિયાન એક જ મોડેલ: FreeLLMAPI વાતચીતને 30 મિનિટ સુધી એક મોડેલ પર રાખે છે. tool loop સામાન્ય રીતે એક મોડેલ પર રહે છે. જો મર્યાદા ફેરફાર કરાવે, તો આગલા મોડેલને tool પરિણામો સહિત સંપૂર્ણ message ઇતિહાસ મળે છે.

મુશ્કેલી નિવારણ

સમસ્યાકારણઉકેલ
મોડેલ લખાણમાં જવાબ આપે છે અને કોઈ tool કૉલ કરતું નથીમોડેલ tools માં નબળું છે, અથવા વર્ણન સ્પષ્ટ નથીકોષ્ટકમાંથી મજબૂત મોડેલ પિન કરો, અથવા tool નું વર્ણન સુધારો
arguments પર json.JSONDecodeErrorમોડેલે માન્ય ન હોય તેવું JSON મોકલ્યુંભૂલ પકડો અને તેને tool પરિણામ તરીકે પાછી મોકલો, જેથી મોડેલ ફરી પ્રયાસ કરી શકે
tool message વિશે ભૂલ 400tool_call_id મેળ ખાતો નથી, અથવા assistant message ખૂટે છેપહેલા assistant message ઉમેરો, પછી દરેક call માટે એક tool message
agent કાર્ય દરમિયાન ભૂલ 429loop ઘણી મોટી વિનંતીઓ મોકલે છેવધુ પ્રદાતા કી ઉમેરો, અને ઓછા tools મોકલો
loop અટકતો નથીમોડેલ એ જ tool ફરીથી કૉલ કરે છેround મર્યાદા સેટ કરો, અને સ્પષ્ટ પરિણામો પરત કરો
આ બધાનો ઉપયોગ એક જ કી દ્વારા કરો. FreeLLMAPI એક ઓપન-સોર્સ, સ્વ-હોસ્ટેડ રાઉટર છે. તે આ બધા મફત ટાયરને એક OpenAI સાથે સુસંગત એન્ડપોઇન્ટ પાછળ મૂકે છે અને જ્યારે એક મૉડેલની રેટ મર્યાદા આવે ત્યારે બીજા પર આપમેળે સ્વિચ કરે છે. કૅટલૉગ બ્રાઉઝ કરો અથવા લાઇવ જાઓ.

વારંવાર પૂછાતા પ્રશ્નો

કઈ મફત LLM API function calling સપોર્ટ કરે છે?

Gemini, Groq, Cerebras, Mistral, OpenRouter, Cloudflare અને બીજા પ્રદાતાઓ પાસે tool calling સાથે મફત મોડેલ છે. FreeLLMAPI catalog માં આજે tools સાથે 190 મફત મોડેલ ઑફર છે.

શું tool calling એ function calling જેવું જ છે?

હા. OpenAI એ પહેલા function calling નામ વાપર્યું. હાલનો API tools અને tool_calls વાપરે છે. બંને નામોનો અર્થ એક જ છે: મોડેલ તમારા કોડને function ચલાવવા કહે છે.

શું OpenAI ફોર્મેટ સાથે Gemini tool calling કામ કરે છે?

હા, FreeLLMAPI દ્વારા. ગેટવે OpenAI tools ને Gemini functionDeclarations માં રૂપાંતરિત કરે છે, અને જવાબને પાછો OpenAI tool_calls માં રૂપાંતરિત કરે છે.

શું tool calls stream કરી શકાય?

હા. stream=True સાથે તમને delta.tool_calls chunks અને tool_calls નો અંતિમ finish_reason મળે છે. parse કરતા પહેલાં argument chunks જોડો.

સંબંધિત માર્ગદર્શિકાઓ

સ્રોતો

બધી માર્ગદર્શિકાઓ · બધા મફત મૉડેલ જુઓ