fit_req_to_vertex_specs!

in lib/anthropic/vertex/client.rb [164:207]


      def fit_req_to_vertex_specs!(request_components)
        if (body = request_components[:body]).is_a?(Hash)
          body[:anthropic_version] ||= DEFAULT_VERSION

          if (anthropic_beta = body.delete(:"anthropic-beta"))
            request_components[:headers] ||= {}
            request_components[:headers]["anthropic-beta"] = anthropic_beta.join(",")
          end
        end

        if %w[
          v1/messages
          v1/messages?beta=true
        ].include?(request_components[:path]) && request_components[:method] == :post

          unless body.is_a?(Hash)
            raise Anthropic::Error, "Expected json data to be a hash for post /v1/messages"
          end

          model = body.delete(:model)
          specifier = body[:stream] ? "streamRawPredict" : "rawPredict"

          request_components[:path] =
            "projects/#{@project_id}/locations/#{region}/publishers/anthropic/models/#{model}:#{specifier}"

        end

        if %w[
          v1/messages/count_tokens
          v1/messages/count_tokens?beta=true
        ].include?(request_components[:path]) &&
           request_components[:method] == :post
          request_components[:path] =
            "projects/#{@project_id}/locations/#{region}/publishers/anthropic/models/count-tokens:rawPredict"

        end

        if request_components[:path].start_with?("v1/messages/batches/")
          raise AnthropicError("The Batch API is not supported in the Vertex client yet")
        end

        request_components
      end