Skip to content

[Bug]: Errors with perplexity and anthropic calls with Tools #11665

@simonljn

Description

@simonljn

What happened?

Reopening with python example.

I try to call different models with tool calls. Working on openai but not on some other ( sonar / claude )

Using : litellm 1.71.1

Is this planned to be supported ?


import openai

client = openai.OpenAI(api_key="TOKEN",base_url="LITELLM-SERVER")

response = client.chat.completions.create(model="PERPLEXITYMODEL", messages = [
      {
        "role": "assistant",
        "tool_calls": [
          {
            "function": {
              "arguments": '{"query":"foobar"}',
              "name": "Search",
            },
            "id": "call_ShUM9uxonziXPYjU9a4uoy4s",
            "type": "function",
          },
        ],
      },
      {
        "content": "this is a tool response",
        "role": "tool",
        "tool_call_id": "call_ShUM9uxonziXPYjU9a4uoy4s",
      },
      {
        "content": "hi",
        "role": "user",
      },
    ])

'litellm.BadRequestError: PerplexityException - ["At body -> messages -> 0 -> content: Field required", "At body -> messages -> 1 -> role: Input should be 'system', 'user' or 'assistant'"].

Thank you

Relevant log output

Are you a ML Ops Team?

No

What LiteLLM version are you on ?

v1.71.1

Twitter / LinkedIn details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions