Skip to content

Support for Chat Completion Endpoints with Tool Execution in Strands #1170

@pradeepdev-1995

Description

@pradeepdev-1995

Problem Statement

Enable Strands Agents to execute tools and handle function-calling workflows when using external Chat Completion APIs (e.g., https://.../chat/completions) — similar to how OpenAI’s chat/completions endpoint supports tools and tool_choice parameters.
Current Behavior
At present, Strands Agents can invoke LLMs through SDK-based models (e.g., OpenAIModel, GeminiModel, etc.), which support tool execution and structured responses via the internal orchestration framework.

However, when integrating chat-based APIs directly through HTTP calls (e.g., REST endpoints that accept model, messages, and tools in the payload), there is no current mechanism to:

Register or expose available tools to the endpoint.

Enable automatic tool selection or invocation.

Maintain consistent agent behavior between SDK-based models and REST-based chat endpoints.

Proposed Solution

Add support for executing a Strands Agent where:

The LLM backend is a generic chat completion API (not an SDK model).

The request payload includes:

model: name or identifier of the chat model.

messages: the conversation history.

tools: array of available tools/functions with schema definitions.

tool_choice: specifying auto or explicit tool invocation.

The agent runtime orchestrates:

Dynamic tool registration and schema construction.

Routing of function calls from LLM responses.

Seamless fallback between SDK and endpoint-based executions.

Use Case

curl -X POST "https://example.com/v1/chat/completions" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <token>" \
  -d '{
    "model": "gpt-4.1",
    "messages": [
      {"role": "user", "content": "What’s the weather in Boston today?"}
    ],
    "tools": [
      {
        "type": "function",
        "function": {
          "name": "get_current_weather",
          "description": "Get the current weather in a given location",
          "parameters": {
            "type": "object",
            "properties": {
              "location": {"type": "string"},
              "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
            },
            "required": ["location"]
          }
        }
      }
    ],
    "tool_choice": "auto"
  }'

The goal is for the Strands Agent to handle the above workflow — parsing the LLM response, triggering the corresponding tool, and returning the result back to the chat completion endpoint seamlessly.

Alternatives Solutions

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions