Skip to content

feat(llms): add together as an openai-compatible provider - #8015

Open
shaikn6 wants to merge 7 commits into
crewAIInc:mainfrom
shaikn6:feat/together-native-provider
Open

shaikn6 wants to merge 7 commits into
crewAIInc:mainfrom
shaikn6:feat/together-native-provider

Conversation

@shaikn6

@shaikn6 shaikn6 commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Related issue

Fixes #8011

Summary

Registers together in OPENAI_COMPATIBLE_PROVIDERS and the factory routing tables (SUPPORTED_NATIVE_PROVIDERS, PROVIDER_ALIASES, _matches_provider_pattern, _get_native_provider), following the DeepInfra change in #7459. LLM(model="together/<org>/<model>") and provider="together" now build OpenAICompatibleCompletion without LiteLLM.

  • Endpoint https://api.together.ai/v1, key from TOGETHER_API_KEY, optional TOGETHER_BASE_URL override.
  • Explicit api_key / base_url take precedence over the env vars; OPENAI_API_KEY / OPENAI_BASE_URL are never used, and a missing key raises an error naming TOGETHER_API_KEY.
  • Only the together/ prefix is removed, so org/model ids reach the SDK intact. No model catalog is hard-coded.
  • is_litellm=True still selects the LiteLLM path.

Verification

  • Tests added or updated for the changed behavior
  • Relevant tests and quality checks pass locally

New TestHostedProviders in tests/llms/openai_compatible/test_openai_compatible.py, parametrized by provider. It covers config, prefixed and explicit-provider routing (org/model preserved), OpenAI env isolation, missing-key error, TOGETHER_BASE_URL, explicit precedence, the is_litellm=True path, and sync and async calls through an httpx.MockTransport that checks the URL, Authorization header and model id sent. No network or paid calls.

test_prefixed_models_with_non_native_providers_use_litellm used together/ as a LiteLLM-only example; it now uses sambanova/.

uv run pytest tests/llms/ tests/test_llm.py tests/test_llm_overlay.py tests/utilities/test_converter.py
1089 passed, 23 skipped

With the source change reverted, 7 of the new tests fail. ruff check on the changed source files is clean.

Additional context

The same test class is introduced by #8013 (Groq) and #8014 (Fireworks AI); whichever merges later needs a one-row rebase of HOSTED_PROVIDER_CASES, which I'll handle.

Docs: there was no Together AI section, so this adds one after Fireworks AI in docs/edge/{en,ar,ko,pt-BR}/concepts/llms.mdx, with the native-client note, both env vars, an example and a link to Together's model list. Frozen docs/v*/ snapshots are unchanged.

Prepared with AI assistance (Claude Code), per CONTRIBUTING. I don't have permission to apply the llm-generated label, so could a maintainer add it?


Note

Medium Risk
Changes default routing for together/ models from LiteLLM to the native client (opt-out via is_litellm=True), which affects credentials, endpoints, and runtime behavior for existing Together users.

Overview
Adds native Together AI support so LLM(model="together/<org>/<model>") (or provider="together") routes to OpenAICompatibleCompletion instead of LiteLLM. Configuration uses https://api.together.ai/v1, TOGETHER_API_KEY, and optional TOGETHER_BASE_URL; only the together/ prefix is stripped so org/model ids reach the API unchanged. is_litellm=True still forces the LiteLLM path.

OpenAICompatibleCompletion gains catalog-aware get_context_window_size() (Together maps to together_ai/ in the context window catalog). Docs add a Together AI section in en, ar, ko, and pt-BR llms.mdx.

Tests add parametrized TestHostedProviders (routing, env isolation from OPENAI_*, sync/async HTTP mocks) and catalog context-window checks; the LiteLLM-only routing example switches from together/ to sambanova/.

Reviewed by Cursor Bugbot for commit 84b9d9d. Bugbot is set up for automated code reviews on this repo. Configure here.

Register together in the OpenAI-compatible provider registry so
LLM(model="together/<org>/<model>") and provider="together" route natively
through OpenAICompatibleCompletion with TOGETHER_API_KEY and no LiteLLM
install. TOGETHER_BASE_URL overrides the endpoint, explicit
api_key/base_url win over both env vars, and OPENAI_* settings are never
used. Only the together/ prefix is removed, so org/model ids reach the API
intact; no model catalog is hard-coded. is_litellm=True keeps the LiteLLM
path.

The test that used together/ as a LiteLLM-only prefix now uses
sambanova/. A Together AI docs accordion is added in en, ar, ko and pt-BR.

Fixes crewAIInc#8011
@strix-security

strix-security Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Strix Security Review

Warning

This pull request has 109 commits after the last Strix review (eb5cb50). Strix has not reviewed these changes.
Automatic review on push is off for this repository. To review the latest changes, tag @strix-security in a comment, or turn on re-review on push.

No security issues found.

Review summary

PR #8015 registers together as a native OpenAI-compatible provider. The changes are confined to provider routing tables and configuration: adding "together" to SUPPORTED_NATIVE_PROVIDERS, PROVIDER_ALIASES, the native OpenAI-compatible provider set, a _matches_provider_pattern branch that returns True, and a ProviderConfig reading TOGETHER_API_KEY/TOGETHER_BASE_URL. This mirrors the existing DeepInfra/Cerebras/DashScope pattern and introduces no attacker-controlled data flow into any dangerous sink, no hardcoded credentials, and no removed security controls. The accompanying edits are translated documentation and tests. No security vulnerabilities were identified in the changed code.

Updated for eb5cb50.


Reviewed by Strix
Re-run review · Configure security review settings

@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 52a1d0a6-6abe-44d0-b420-4bb73414d25a
📥 Commits

Reviewing files that changed from the base of the PR and between 22b4ec5 and 84b9d9d.

📒 Files selected for processing (3)
  • lib/crewai/src/crewai/llms/providers/openai_compatible/completion.py
  • lib/crewai/tests/llms/openai_compatible/test_openai_compatible.py
  • lib/crewai/tests/test_llm.py

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

📝 Walkthrough

Together AI is now supported through native OpenAI-compatible routing. The provider configuration, localized setup examples, and tests cover model routing, credentials, endpoint selection, context-window lookup, and synchronous and asynchronous completion calls.

Changes: Together AI provider support

Layer / File(s) Summary
Native routing and provider configuration
lib/crewai/src/crewai/llm.py, lib/crewai/src/crewai/llms/providers/openai_compatible/completion.py, docs/edge/.../concepts/llms.mdx
The LLM factory recognizes Together model names and routes them through OpenAICompatibleCompletion. The provider configuration defines its endpoint and environment variables. Context-window lookup checks the provider-qualified model ID, then the model ID, and falls back to the default. Four localized guides document setup and model IDs.
Routing and request validation
lib/crewai/tests/llms/openai_compatible/test_openai_compatible.py, lib/crewai/tests/test_llm.py
Tests cover routing, context-window lookup, credential and endpoint precedence, missing-key behavior, the explicit LiteLLM path, and synchronous and asynchronous requests. The existing LiteLLM routing test now uses SambaNova.

Sequence Diagram(s)

sequenceDiagram
  participant LLM as LLM construction
  participant Factory as LLM factory
  participant Completion as OpenAICompatibleCompletion
  participant Together as Together API
  LLM->>Factory: Resolve together/org/model
  Factory->>Completion: Select native provider and pass model ID
  Completion->>Together: Send request using configured endpoint and API key
  Together-->>Completion: Return completion response
Loading

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 84b9d

No actionable issue remains from this review; the PR is mergeable after normal checks.

Pre-merge checks · Passed 4 · Failed 1

Failed Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 21 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks (4 passed)
Check name Status Explanation
Description check Passed The description includes the required Related issue, Summary, Verification, and Additional context sections. It explains the implementation, compatibility behavior, tests, and validation results.
Title check Passed The title clearly and concisely identifies the main change: adding Together as an OpenAI-compatible provider.
Linked Issues check Passed Issue #8011 requirements are met. The PR registers together for native routing and explicit provider="together" selection. It uses https://api.together.ai/v1, TOGETHER_API_KEY, and optional `T…
Out of Scope Changes check Passed The changes stay within issue #8011. Source changes extend the existing OpenAI-compatible registry, routing, configuration, and context-window lookup. Tests cover the requested behavior and update the…
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Routing together natively sent its models through the OpenAI-only lookup,
which resolves 72 of the 79 together_ai ids in the catalog to a different
limit than the catalog lists. The lookup now uses the catalog's name for
the provider with the model id first and the id as given second.
@shaikn6

shaikn6 commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

Merged main and added a context-window lookup that follows #8077.

Once together routes natively, its models go through the inherited OpenAI lookup, which resolves 72 of the 79 together_ai/ ids in the catalog to a different limit than the catalog lists. OpenAICompatibleCompletion.get_context_window_size now resolves the catalog's together_ai/model id in LLM_CONTEXT_WINDOW_SIZES first and the id as given second; a test checks every together_ai/ id in the catalog against its own limit. #8013 and #8014 carry the same method; this one adds the small name mapping, since the catalog says together_ai where this provider is registered as together.

@shaikn6

shaikn6 commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Brought the branch up to date with main. One check failed: tests/telemetry/test_flow_telemetry.py::test_infrastructure_flows_do_not_pollute_outcome_signals (assert ('AgentExecutor', 'completed') in []). It isn't related to this change. The same test passed on #8013/#8014/#8016/#8062 against the same main, and it passes 3/3 locally on this head (25 passed). I can't re-run jobs here, so could a maintainer re-run the failed ones?

@mintlify

mintlify Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 71e7c3f.

Approve preview

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add Together AI to native OpenAI-compatible provider routing

1 participant